/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 772.0 KiB
#3 Wrong Answer 5ms 540.0 KiB

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