81362024-01-12 14:18:25anonGyros (30)cpp17Wrong answer 17/303ms3748 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 && B >= 2 && cc && bc)
                break;
        }
        while(A >= 2 && cc) {
            ans++;
            cc--;
            A -= 2;
        }
        while(B >= 2 && bc) {
            ans++;
            bc--;
            B -= 2;
        }
        cout << ans << '\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base17/30
1Accepted0/03ms1956 KiB
2Accepted0/03ms2120 KiB
3Accepted2/23ms2288 KiB
4Accepted2/23ms2484 KiB
5Accepted2/23ms2672 KiB
6Accepted3/33ms2744 KiB
7Accepted3/33ms2852 KiB
8Accepted3/33ms2824 KiB
9Accepted2/23ms2960 KiB
10Wrong answer0/23ms3184 KiB
11Wrong answer0/23ms3292 KiB
12Wrong answer0/33ms3592 KiB
13Wrong answer0/33ms3748 KiB
14Wrong answer0/33ms3724 KiB