| Task: | ABC-poisto |
| Sender: | hltk |
| Submission time: | 2020-10-16 20:12:45 +0300 |
| Language: | C++ (C++17) |
| 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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int c[3]{};
for (auto &u : s)
c[u - 'A']++;
int k = 0;
while (!!c[0] + !!c[1] + !!c[2] > 1) {
sort(begin(c), end(c));
c[1]--;
c[2]--;
k += 2;
}
cout << k << '\n';
}
}
