태윤2 2020. 10. 25. 21:04

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import heapq
import sys
= int(sys.stdin.readline())
= [int(sys.stdin.readline()) for _ in range(n)]
= []
 
for i in a:
    if i == 0:
        if q:
            print(-heapq.heappop(q))
        else:
            print(0)
    else :
      heapq.heappush(q, -i)
cs