문제
11279번과 같이 힙을 이용하여 우선순위 큐를 구현하면 된다!
import sys
import heapq
input = sys.stdin.readline
n = int(input())
heap = []
#Max Heap
for _ in range(n):
    x = int(input())
    if x != 0:
        heapq.heappush(heap, x)
    else:
        try:
            print(heapq.heappop(heap))
        except:
            print(0)