Task: | ABC-poisto |
Sender: | mango_lassi |
Submission time: | 2020-10-17 19:03:10 +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; using ll = long long; void solve() { string str; cin >> str; int n = str.size(); vector<int> cou(3, 0); for (auto c : str) cou[c - 'A'] += 1; int mx = max(cou[0], max(cou[1], cou[2])); cout << min(2 * (n - mx), n - (n % 2)) << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; for (int ti = 0; ti < t; ++ti) solve(); }