244일차 - BOJ no.10773

https://www.acmicpc.net/problem/10773

My Solution

import sys

arr = []
K = int(sys.stdin.readline().rstrip())
for _ in range(K):
   n = int(sys.stdin.readline().rstrip())
   if n != 0:
       arr.append(n)
   else:
       arr.pop()

print(sum(arr))

#스택

좋은 웹페이지 즐겨찾기