Submission

Status:

----------

Subtask/Task Score:

0/100

Score: 0

User: mzmvtbgf

Problemset: ดีกค์เวิร์ด

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-13 10:58:06

#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;

int cost(int xx, int yy, int now)
{
    if (yy > xx) return 0;
    int pos = xx+yy+1;
    int val = 0;
    if (xx < n)
    {
        val += cost(xx + 1, yy, now + pos*a);
    } 
    if (yy < n) 
    {
        val += cost(xx, yy + 1, now + pos*b);
    }
    return max(val, now);
}

//2///4 + 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    char ca, cb;
    cin >> ca >> cb;
    a = ca - 'A' + 1;
    b = cb - 'A' + 1;
    cout << a << " " << b << "\n";
    cout << cost(0, 0, 0);
    return 0;
}