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

[백준/파이썬] 32046번 Snacks within 300 Yen

by 현장 2024. 7. 15.

-Code

while True:
    n = int(input())

    if n == 0:
        break
    res = 0
    snacks = list(map(int, input().split()))

    for p in snacks:
        if res + p <= 300:
            res += p

    print(res)