Task: | ABC-poisto |
Sender: | Sisuaski |
Submission time: | 2020-10-17 04:23:14 +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 <iostream> #include <algorithm> using namespace std; int main() { int t;cin>>t; while(t--){ string s;cin>>s; int cnt[3]={}; for(char c:s)cnt[c-'A']++; int x = max({cnt[0],cnt[1],cnt[2]}); int n = s.size(); int r = 2*x<=n ? n-(n&1) : 2*(n-x); cout<<r<<'\n'; } }