여름의 서재

[백준] 1927_최소 힙 본문

알고리즘/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)

'알고리즘 > BOJ' 카테고리의 다른 글

[백준] 1992_쿼드트리  (0) 2021.08.12
[백준] 1931_회의실 배정  (0) 2021.08.12
[백준] 1920_수 찾기  (0) 2021.08.12
[백준] 1874_스택 수열  (0) 2021.08.12
[백준] 1654_랜선 자르기  (0) 2021.08.12
Comments