Task: | ABC-poisto |
Sender: | hltk |
Submission time: | 2020-10-19 11:20:23 +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> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int c[3]{}; for (char u : s) c[u - 'A']++; int n = s.size(), m = max({c[0], c[1], c[2]}); cout << (m * 2 <= n ? n - n % 2 : (n - m) * 2) << '\n'; } }