본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 25965번 미션 도네이션

by 현장 2024. 4. 14.

-Code

for _ in range(int(input())):
    res = 0
    mission = [list(map(int, input().split())) for _ in range(int(input()))]
    my_k, my_d, my_a = map(int, input().split())

    for k, d, a in mission:
        total = my_k * k - my_d * d + my_a * a
        if total < 0:
            continue

        res += total

    print(res)