81462024-01-12 14:35:43anonGyros (30)cpp17Accepted 30/303ms3820 KiB
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    string s;
    ll i, cc, bc, vc, pp, ans, T, N, A, B;
    cin >> T;
    while(T--) {
        cin >> N >> A >> B >> s;
        cc = bc = vc = 0;
        for(i = 0; i < N; i++) {
            switch(s[i]) {
                case 'C':
                    cc++;
                    break;
                case 'B':
                    bc++;
                    break;
                case 'V':
                    vc++;
            }
        }
        ans = min(cc, A / 2) + min(bc, B / 2);
        pp = 0;
        while(vc && A && B) {
            pp++;
            vc--;
            A--;
            B--;
            ans = max(ans, pp + min(cc, A / 2) + min(bc, B / 2));
        }
        cout << ans << '\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1824 KiB
2Accepted0/03ms2172 KiB
3Accepted2/23ms2232 KiB
4Accepted2/23ms2452 KiB
5Accepted2/23ms2532 KiB
6Accepted3/33ms2924 KiB
7Accepted3/33ms2880 KiB
8Accepted3/32ms2984 KiB
9Accepted2/23ms3116 KiB
10Accepted2/23ms3172 KiB
11Accepted2/23ms3320 KiB
12Accepted3/33ms3312 KiB
13Accepted3/33ms3596 KiB
14Accepted3/33ms3820 KiB