21702022-12-28 11:20:25kohumarkGyros (30)cpp11Accepted 30/303ms3668 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin >> n; int sol[n];
	for(int i=0; i<n; i++){
		int v, c, b;
		cin >> v >> c >> b;
		int vo=0; int bo=0; int co=0;
		string rend; cin >> rend;
		for(int i=0; i<v; i++){
			if(rend[i] == 'V') vo++;
			if(rend[i] == 'B') bo++;
			if(rend[i] == 'C') co++;
		}
		int kesz = 0;
		if(vo <= b && vo <= c){
			if(((b-vo)%2 && ((b-vo)/2<bo)) || ((c-vo)%2 && ((c-vo)/2<co))) vo--;
			kesz += vo;
			b-=vo; c-=vo;		
		}
		else if(vo>b && vo<c){
			c-=b;
			kesz += b; b=0;
		}
		else{
			b-=c;
			kesz +=c; c=0;
		}
		if(b/2>=bo) kesz+=bo; else kesz+=b/2;
		if(c/2>=co) kesz+=co; else kesz+=c/2;
		sol[i]=kesz;
	}
	for(int i=0; i<n; i++) cout << sol[i] << endl;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1816 KiB
2Accepted0/02ms2084 KiB
3Accepted2/22ms2120 KiB
4Accepted2/22ms2336 KiB
5Accepted2/22ms2424 KiB
6Accepted3/32ms2548 KiB
7Accepted3/32ms2772 KiB
8Accepted3/32ms2972 KiB
9Accepted2/22ms3080 KiB
10Accepted2/22ms3036 KiB
11Accepted2/22ms3148 KiB
12Accepted3/32ms3264 KiB
13Accepted3/33ms3468 KiB
14Accepted3/33ms3668 KiB