Wrong Answer
Code
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define trace(x) cout << #x << ": " << x << endl
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; cin >> t;
while(t--)
{
int n, k; cin >> n >> k;
string s; cin >> s;
int cntA = 0, cntB = 0, cnt = 0;
for(auto u : s)
{
if(u == 'A') cntA++;
if(u == 'B') cntB++;
if(u == '?') cnt++;
}
int ans = cntA * (min(k, cnt) + cntB);
ans = max(ans, cntB * (min(k, cnt) + cntA));
cout << ans << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1110 Subsequence of AB
- Contest
- LU IUJPC : Sylhet Division 2024, Mock Round
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-12-07 10:54:12
- Judged At
- 2024-12-07 10:54:12
- Judged By
- Score
- 1
- Total Time
- 5ms
- Peak Memory
- 772.0 KiB