Task: | ABC-poisto |
Sender: | Laakeri |
Submission time: | 2020-10-17 16:31:41 +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; void solve() { string s; cin>>s; vector<int> a(3); for (int i=0;i<(int)s.size();i++){ if (s[i]=='A'){ a[0]++; } if (s[i]=='B'){ a[1]++; } if (s[i]=='C'){ a[2]++; } } int ans=0; while(1){ sort(a.begin(), a.end()); if (a[1]==0) break; ans+=2; a[1]--; a[2]--; } cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int tcs; cin>>tcs; for (int tc=1;tc<=tcs;tc++){ solve(); } }