| Task: | ABC-poisto |
| Sender: | tykkipeli |
| Submission time: | 2020-10-16 19:30:48 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 42 |
| #2 | ACCEPTED | 58 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2 | details |
| #2 | ACCEPTED | 0.01 s | 2 | details |
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void testCase() {
string str;
cin >> str;
int n = str.size();
int a = 0, b = 0, c = 0;
for (int i = 0; i < n; i++) {
if (str[i] == 'A') a++;
else if (str[i] == 'B') b++;
else c++;
}
int suurin = max(a,max(b,c));
int left = n-suurin;
int ans = min(n,2*left);
if (ans%2 == 1) ans--;
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
for (int i = 0; i < t; i++) {
testCase();
}
}
