CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:ABC-poisto
Sender:Laakeri
Submission time:2020-10-17 16:31:41 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED42
#2ACCEPTED58
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <bits/stdc++.h>
using namespace std;

void solve() {
	string s;
	cin>>s;
	vector<int> a(3);
	for (int i=0;i<(int)s.size();i++){
		if (s[i]=='A'){
			a[0]++;
		}
		if (s[i]=='B'){
			a[1]++;
		}
		if (s[i]=='C'){
			a[2]++;
		}
	}
	int ans=0;
	while(1){
		sort(a.begin(), a.end());
		if (a[1]==0) break;
		ans+=2;
		a[1]--;
		a[2]--;
	}
	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tcs;
	cin>>tcs;
	for (int tc=1;tc<=tcs;tc++){
		solve();
	}
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
100
CABC
BABCCBCA
CBBCBBAC
ACAA
...

correct output
4
8
8
2
2
...

user output
4
8
8
2
2
...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
100
CCAAACBCBBCCACBBBCCACCCBABBCAB...

correct output
48
4
4
96
70
...

user output
48
4
4
96
70
...
Truncated