32092023-02-22 14:27:5612BotiGyros (30)python3Accepted 30/3024ms14080 KiB
from operator import itemgetter
from collections import Counter

for _ in range(int(input())):
    n, ca, ba = map(int, input().split())
    v, b, c = itemgetter(*"VBC")(Counter(input()))
    if ca < ba:
        ca, ba = ba, ca
        c, b = b, c
    # print(v, b, c)
    r = 0
    while ca >= 2 and c > 0:
        assert ca >= ba
        ca -= 2
        c -= 1
        r += 1
        if ca < ba:
            ca, ba = ba, ca
            c, b = b, c
    while ca > 0 and ba > 0 and v > 0:
        ca -= 1
        ba -= 1
        v -= 1
        r += 1
    r += min(c, ca // 2)
    r += min(b, ba // 2)
    print(r)
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/020ms11892 KiB
2Accepted0/023ms12472 KiB
3Accepted2/219ms12504 KiB
4Accepted2/221ms12720 KiB
5Accepted2/219ms12496 KiB
6Accepted3/320ms12980 KiB
7Accepted3/320ms13128 KiB
8Accepted3/320ms13076 KiB
9Accepted2/220ms13372 KiB
10Accepted2/220ms13632 KiB
11Accepted2/220ms13616 KiB
12Accepted3/320ms13624 KiB
13Accepted3/323ms13960 KiB
14Accepted3/324ms14080 KiB