14332022-09-30 13:37:24mraronGyros (30)cpp17Accepted 30/303ms3564 KiB
#include<bits/stdc++.h>
using namespace std;

int main() {
    int T;
    cin>>T;
    while(T--) {
        int n,c,b;
        cin>>n>>c>>b;
        string s;
        cin>>s;
        int cntV=0, cntC=0, cntB=0;
        for(char c:s) {
            if(c=='V') cntV++;
            if(c=='C') cntC++;
            if(c=='B') cntB++;
        }
        
        int ans=0;
        for(int v=0;v<=cntV;++v) {
            if(c-v>=0 && b-v>=0)
                ans=max(ans, v+min((c-v)/2, cntC)+min((b-v)/2, cntB));
        }
        
        cout<<ans<<"\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1812 KiB
2Accepted0/02ms2032 KiB
3Accepted2/22ms2228 KiB
4Accepted2/22ms2584 KiB
5Accepted2/22ms2504 KiB
6Accepted3/32ms2508 KiB
7Accepted3/32ms2668 KiB
8Accepted3/32ms2704 KiB
9Accepted2/22ms2940 KiB
10Accepted2/22ms3072 KiB
11Accepted2/22ms3104 KiB
12Accepted3/32ms3240 KiB
13Accepted3/33ms3464 KiB
14Accepted3/33ms3564 KiB