CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:ABC-poisto
Sender:jnalanko
Submission time:2020-10-16 22:48:02 +0300
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED42
#2ACCEPTED58
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
//#include "stdlib_printing.hh"

using namespace std;
typedef long long LL;


void solve(){
    string S; cin >> S;
    LL na = 0; LL nb = 0; LL nc = 0;
    for(char c : S){
        if(c == 'A') na++;
        if(c == 'B') nb++;
        if(c == 'C') nc++;
    }
    vector<LL> v = {na,nb,nc};
    sort(v.begin(), v.end());
    if(v[2] >= v[0] + v[1]) cout << S.size() - (v[2] - v[0] - v[1]) << "\n";
    else cout << S.size() - S.size() % 2 << "\n";

}

int main(int argc, char** argv){
    LL t; cin >> t; while(t--) solve();
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
100
CABC
BABCCBCA
CBBCBBAC
ACAA
...

correct output
4
8
8
2
2
...

user output
4
8
8
2
2
...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
100
CCAAACBCBBCCACBBBCCACCCBABBCAB...

correct output
48
4
4
96
70
...

user output
48
4
4
96
70
...
Truncated