54562023-06-22 13:32:07TuruTamasGyros (30)cpp17Wrong answer 9/304ms3796 KiB
#include "bits/stdc++.h"
#include <algorithm>
#include <cstddef>
#include <fstream>
#include <string>
#include <iostream>

using namespace std;

int main() {
    // string path;
    // cin >> path;
    // auto f = ifstream(path);
    int T;
    cin >> T;
    for (int i = 0; i < T; i++) {
        int N, csikke, boci, V, C, B;
        V = C = B = 0;
        cin >> N >> csikke >> boci;
        for (int k = 0; k < N; k++) {
            char c;
            cin >> c;
            if (c == 'C')
                C++;
            else if (c == 'B')
                B++;
            else if (c == 'V')
                V++;
        }
        int vegyes_max = min({C, B, V});
        int csirke_max = min(csikke/2, C);
        int boci_max = min(boci/2, B);
        bool f = false;
        int l = -69420;
        int i2 = 0;
        for (int j = 0; j < vegyes_max; ++j) {
            int val = j + min((csikke-j)/2, C) + min((boci-j)/2, B);
            if (val <= l) 
                break;
            l = val;
            i2 = j;
        }
        // cout << "DEBUG: " << i2 << ' ' << vegyes_max << ' '  << C << ' ' << B <<  ' ' << 
        //     i2 + min((csikke-i2)/2, C) + min((boci-i2)/2, B) <<  ' ' << vegyes_max + min((csikke-vegyes_max)/2, C) + min((boci-vegyes_max)/2, B) << "\n";
        cout << max(
            i2 + min((csikke-i2)/2, C) + min((boci-i2)/2, B),
            vegyes_max + min((csikke-vegyes_max)/2, C) + min((boci-vegyes_max)/2, B)
        );
        cout << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base9/30
1Accepted0/03ms1748 KiB
2Accepted0/04ms1912 KiB
3Accepted2/23ms2124 KiB
4Wrong answer0/23ms2336 KiB
5Accepted2/23ms2544 KiB
6Wrong answer0/33ms2792 KiB
7Wrong answer0/33ms2972 KiB
8Wrong answer0/33ms3216 KiB
9Wrong answer0/23ms3268 KiB
10Wrong answer0/23ms3384 KiB
11Accepted2/23ms3396 KiB
12Wrong answer0/33ms3588 KiB
13Accepted3/33ms3676 KiB
14Wrong answer0/34ms3796 KiB