https://www.acmicpc.net/problem/1927 최소 힙. # -*- encoding: cp949 -*- from heapq import * h = [] for n in xrange(input()): x=input() if x==0: if len(h)==0: print 0 else: print heappop(h) else: heappush(h,x) https://www.acmicpc.net/problem/11279 위는 최소 힙. 이번문제는 최대 힙이다. 파이썬에는 최대 힙이 구현되어 있지 않다. 어떻게 할까..? 스택오버플로우에서 봤는데 어떤분이 '최소 힙을 사용하되, 숫자를 넣을때 -로 넣고 뺄때 -를 붙이면 최대 힙이 되!' 라는 답글을 보고 천재라고 생각했다..... # -*- ..