728x90
SMALL
k = int(input())
stack = list()
for _ in range(k):
num = int(input())
if num != 0:
stack.append(num)
else:
stack.pop()
print(sum(stack))
728x90
LIST
'취준시절 > 백준' 카테고리의 다른 글
[백준 9012] 괄호 - Python (0) | 2021.07.09 |
---|---|
[백준 1874] 스택 수열 - Python (0) | 2021.07.09 |
[백준 10828] 스택 - Python (0) | 2021.07.05 |
[백준 3187] 양치기 꿍 - Python (0) | 2021.07.05 |
[백준 11725] 트리의 부모 찾기 - Python (0) | 2021.07.01 |