81242024-01-12 14:08:19anonGyros (30)cpp17Wrong answer 14/303ms3388 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 || A == 3) && cc >= 1)) || ((B == 2 || B == 3) && 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
base14/30
1Accepted0/03ms1824 KiB
2Accepted0/03ms2216 KiB
3Accepted2/23ms2232 KiB
4Accepted2/23ms2748 KiB
5Accepted2/23ms2732 KiB
6Accepted3/33ms2752 KiB
7Wrong answer0/33ms2772 KiB
8Accepted3/33ms2760 KiB
9Accepted2/23ms2944 KiB
10Wrong answer0/23ms3024 KiB
11Wrong answer0/23ms3028 KiB
12Wrong answer0/33ms3320 KiB
13Wrong answer0/33ms3388 KiB
14Wrong answer0/33ms3376 KiB