728x90
https://www.acmicpc.net/problem/10773
K = int(input())
stack = []
for i in range(K) :
n = int(input())
if n == 0 :
stack.pop()
else :
stack.append(n)
print(sum(stack))
728x90
'코팅테스트 > 백준' 카테고리의 다른 글
[백준] 2839번: 설탕배달 - Python (0) | 2024.12.04 |
---|---|
[백준] 2869번: 달팽이는 올라가고 싶다 - Python (0) | 2024.12.04 |
[백준] 2805번: 나무 자르기 - java (0) | 2023.04.05 |
[백준] 1654번: 랜선자르기 - JAVA (0) | 2023.04.05 |
[백준] 2231번 : 분해합 - JAVA (0) | 2023.03.09 |