Task: | ABC-poisto |
Sender: | PallomerenPiikki |
Submission time: | 2020-10-18 12:03:51 +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 <bits/stdc++.h>using namespace std;#define int long longint solve(string s) {int n = s.size();vector<int> occ(256);for (char c : s) occ[c]++;int maxocc = *max_element(occ.begin(), occ.end());int others = n - maxocc;if (maxocc > others) {return maxocc - others;}return n % 2;}signed main() {ios::sync_with_stdio(0);int t;cin >> t;while (t--) {string s;cin >> s;int n = s.size();cout << n-solve(move(s)) << '\n';}}