[BOJ / Python] 10773 제로

도니·2023년 4월 21일

BOJ / Python

목록 보기
102/105
post-thumbnail

문제

백준 10773 제로

코드

import sys
K = int(sys.stdin.readline())

nums = []
for _ in range(K):
    tmp = int(sys.stdin.readline())
    if tmp == 0:
        nums.pop()
    else:
        nums.append(tmp)

print(sum(nums))
profile
Where there's a will, there's a way

0개의 댓글