practivceAlgorithm/백준

[백준][Python] 11286 절댓값 힙

findTheValue 2021. 9. 13. 16:55

말 그대로 절댓값 힙

 

import sys
input = sys.stdin.readline
from heapq import heappop,heappush

N = int(input())
arr = []
for _ in range(N):
    x = int(input())
    if x:
        heappush(arr,(abs(x),x))
        continue
    try:
        print(heappop(arr)[1])
    except:
        print(0)