알고리즘/BOJ

[백준] 1927_최소 힙

엉아_ 2021. 8. 12. 01:21
728x90
import sys
import heapq as hq

N = int(input())
heap = []
for _ in range(N):
    X = int(sys.stdin.readline())
    if X :
        hq.heappush(heap,(X))
    else:
        try:print(hq.heappop(heap))
        except:print(0)