[백준][자료구조/힙] 11279.최대 힙 (파이썬/Python) import heapq import sys input = sys.stdin.readline n = int(input()) heap = [] for _ in range(n): x = int(input()) if x != 0: heapq.heappush(heap,[-x,x]) else: try: print(heapq.heappop(heap)[1]) except: print(0) 문제풀이/백준(Boj) 문제풀이 2022.01.08