CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:ABC-poisto
Sender:Gomhog
Submission time:2020-10-16 19:33:53 +0300
Language: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>
typedef long long ll;
typedef long double ld;
#define F first
#define S second

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tst;
	cin>>tst;
	for (int t=0;t<tst;t++) {
		string s;
		cin>>s;
		int cntA=0;
		int cntB=0;
		int cntC=0;
		int n=s.size();
		for (int i=0;i<n;i++) {
			if (s[i]=='A') cntA++;
			if (s[i]=='B') cntB++;
			if (s[i]=='C') cntC++;
		}
		if (cntB+cntC<cntA) {
			cout<<2*(cntB+cntC)<<"\n";
			continue;
		}
		if (cntA+cntC<cntB) {
			cout<<2*(cntA+cntC)<<"\n";
			continue;
		}
		if (cntA+cntB<cntC) {
			cout<<2*(cntA+cntB)<<"\n";
			continue;
		}
		if (n%2==1) n--;
		cout<<n<<"\n";
	}
}

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
...

Test 2

Group: 2

Verdict: ACCEPTED

input
100
CCAAACBCBBCCACBBBCCACCCBABBCAB...

correct output
48
4
4
96
70
...

user output
48
4
4
96
70
...