81302024-01-12 14:12:06anonGyros (30)cpp17Wrong answer 20/303ms3952 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, 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 = 0;
        if(A < B) {
            while(A < B && B >= 2 && bc) {
                ans++;
                bc--;
                B -= 2;
            }
        }
        else {
            while(B < A && A >= 2 && cc) {
                ans++;
                cc--;
                A -= 2;
            }
        }
        while(vc && A && B) {
            ans++;
            vc--;
            A--;
            B--;
            if(vc == 1 && A == 2 && cc >= 1 && B == 2 && bc >= 1)
                break;
        }
        while(A >= 2 && cc) {
            ans++;
            cc--;
            A -= 2;
        }
        while(B >= 2 && bc) {
            ans++;
            bc--;
            B -= 2;
        }
        cout << ans << '\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base20/30
1Accepted0/03ms1828 KiB
2Accepted0/03ms2212 KiB
3Accepted2/23ms2232 KiB
4Accepted2/23ms2456 KiB
5Accepted2/23ms2660 KiB
6Accepted3/33ms2880 KiB
7Accepted3/33ms3244 KiB
8Accepted3/33ms3308 KiB
9Accepted2/22ms3380 KiB
10Wrong answer0/22ms3384 KiB
11Wrong answer0/23ms3648 KiB
12Accepted3/33ms3660 KiB
13Wrong answer0/33ms3680 KiB
14Wrong answer0/33ms3952 KiB