32082023-02-22 14:06:1512BotiGyros (30)python3Wrong answer 14/3024ms14140 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 > ba and ca >= 2 and c > 0:
        ca -= 2
        c -= 1
        r += 1
    while ca > 2 and ba > 2 and v > 0:
        ca -= 1
        ba -= 1
        v -= 1
        r += 1
    if ca > 2 and ba > 2 and v >= 2:
        r += 2
    else:
        r += min(b, ba // 2)
        r += min(c, ca // 2)
    print(r)
SubtaskSumTestVerdictTimeMemory
base14/30
1Accepted0/019ms11992 KiB
2Accepted0/021ms12456 KiB
3Accepted2/220ms12356 KiB
4Wrong answer0/220ms12484 KiB
5Accepted2/219ms12820 KiB
6Wrong answer0/319ms12904 KiB
7Wrong answer0/321ms13336 KiB
8Wrong answer0/320ms13552 KiB
9Wrong answer0/220ms13780 KiB
10Accepted2/219ms13784 KiB
11Accepted2/220ms13856 KiB
12Accepted3/320ms13556 KiB
13Accepted3/321ms14072 KiB
14Wrong answer0/324ms14140 KiB