Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: mzmvtbgf
Problemset: ดีกค์เวิร์ด
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-13 10:58:31
#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 << cost(0, 0, 0);
return 0;
}