import sys
import heapq
heap = []
#파이썬의 경우 일반적인 input을 받게 될 경우 시간이 오래 걸린다.
n = int(sys.stdin.readline())
for i in range(0,n):
x = int(sys.stdin.readline())
fake_x = -x
if x is 0:
if len(heap) is 0:
print(0)
else:
hhhh = (-1)*heapq.heappop(heap)
print(hhhh)
else:
heapq.heappush(heap,fake_x)
'OnlineJudge' 카테고리의 다른 글
Baek Joon Algorithm(백준 알고리즘): 10998번 (0) | 2019.08.27 |
---|---|
Baek Joon Algorithm(백준 알고리즘): 10871번 (0) | 2019.08.27 |
Baek Joon Algorithm(백준 알고리즘): 10869번 (0) | 2019.08.27 |
Baek Joon Algorithm(백준 알고리즘): 10828번 (0) | 2019.08.27 |
Baek Joon Algorithm(백준 알고리즘): 10430번 (0) | 2019.08.27 |