취준시절/백준

[백준 1927] 최소 힙 - Python

MAYMIN 2021. 8. 1. 12:58
728x90
SMALL
import heapq
import sys
input = sys.stdin.readline
n = int(input())
heap = []
for _ in range(n):
    num = int(input())
    if num == 0:
        if len(heap)==0:
            print(0)
        else:
            min = heapq.heappop(heap)
            print(min)
    else:
        heapq.heappush(heap,num)
728x90
LIST