20241216 ○

2044C. Hard Problem

If we put type-c monkeys first, type-a monkeys or type-b monkeys may not be able to have seats.

for _ in range(int(input())):
    m, a, b, c = map(int, input().split())

    a_seated: int = min(a, m)
    b_seated: int = min(b, m)

    ans: int = a_seated + b_seated + min(c, 2 * m - a_seated - b_seated)
    print(ans)

_ lb


TODO:


index 20241215 20241217