백준 1927 파이썬 python : 최소 힙 @@황소처럼 우직하게@@
import sys import heapq input = sys.stdin.readline n = int(input().strip()) q = [] for i in range(n): num = int(input().strip()) if num == 0: if q: print(heapq.heappop(q)) else: print(0) else: heapq.heappush(q, num)