최소 힙 (1) 썸네일형 리스트형 백준 1927 최소 힙 - 파이썬 풀이. 파이썬에서 제공하는 heapq 라이브러리를 이용하면 매우 간단하게 풀 수 있다. 소스코드. import sys import heapq N = int(sys.stdin.readline()) queue = [] for i in range(N): n = int(sys.stdin.readline()) if n >= 1: heapq.heappush(queue, n) elif n == 0: try: print(heapq.heappop(queue)) except: print(0) 이전 1 다음