32092023-02-22 14:27:5612BotiGyros (30)python3Elfogadva 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)
RészfeladatÖsszpontTesztVerdiktIdőMemória
base30/30
1Elfogadva0/020ms11892 KiB
2Elfogadva0/023ms12472 KiB
3Elfogadva2/219ms12504 KiB
4Elfogadva2/221ms12720 KiB
5Elfogadva2/219ms12496 KiB
6Elfogadva3/320ms12980 KiB
7Elfogadva3/320ms13128 KiB
8Elfogadva3/320ms13076 KiB
9Elfogadva2/220ms13372 KiB
10Elfogadva2/220ms13632 KiB
11Elfogadva2/220ms13616 KiB
12Elfogadva3/320ms13624 KiB
13Elfogadva3/323ms13960 KiB
14Elfogadva3/324ms14080 KiB