https://www.acmicpc.net/problem/11286
import sys
import heapq
input = sys.stdin.readline
test_case = int(input())
arr = []
for _ in range(test_case):
x = int(input())
if x != 0:
heapq.heappush(arr, (abs(x), x))
else:
try:
print(heapq.heappop(arr)[1])
except:
print(0)
절대값 힙은 최대 힙과 같이 풀면 된다.