BOJ10773-제로 (python3)

Ok Haeeun·2023년 3월 14일
0

Python3로 algorithm문풀

목록 보기
29/53

스택~

import sys

n = int(sys.stdin.readline())
number_list = []
result = 0
for i in range(n):
    num = int(sys.stdin.readline().rstrip('\n'))
    if num != 0:
        number_list.append(num)
    else:
        number_list.pop()
if len(number_list) > 0:
    for i in number_list:
        result += i
    print(result)
else: print(0)
profile
tistory에 이어서 기록합니다 👉 https://i-m-okay.tistory.com/

0개의 댓글

관련 채용 정보