18212022-12-04 09:38:51sztomiGyros (30)cpp17Wrong answer 25/303ms3460 KiB
#include <bits/stdc++.h>

using namespace std;

void solve(){
    int n, c, b;
    cin >> n >> c >> b;
    int c_db, b_db, v_db;
    c_db = b_db = v_db = 0;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        switch(s[i]){
        case 'C':
            c_db++;
            break;
        case 'B':
            b_db++;
            break;
        case 'V':
            v_db++;
            break;
        }
    }

    int ki = 0;
    if(c > b){
        ki = min(c_db, (c-b) / 2);
        c_db -= ki;
        c -= ki*2;
    }
    else if(c < b){
        ki = min(b_db, (b-c) / 2);
        b_db -= ki;
        b -= ki*2;
    }
    int bc_csinal = min(min(b_db, c_db), min(c, b));
    c -= bc_csinal*2;
    b -= bc_csinal*2;
    ki += bc_csinal*2;
    int v_csinal = min(v_db, min(c, b));
    c -= v_csinal;
    b -= v_csinal;
    ki += v_csinal;
    ki += min(b_db, b/2);
    ki += min(c_db, c/2);
    cout << ki << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while(t--){
        solve();
    }
}
SubtaskSumTestVerdictTimeMemory
base25/30
1Accepted0/03ms1704 KiB
2Accepted0/02ms1888 KiB
3Accepted2/22ms1936 KiB
4Accepted2/22ms2076 KiB
5Accepted2/22ms2268 KiB
6Accepted3/32ms2472 KiB
7Accepted3/32ms2736 KiB
8Accepted3/32ms2784 KiB
9Accepted2/22ms2920 KiB
10Wrong answer0/22ms3152 KiB
11Accepted2/22ms3180 KiB
12Accepted3/32ms3176 KiB
13Accepted3/32ms3460 KiB
14Wrong answer0/32ms3412 KiB