취준시절/백준

[백준 11286] 절댓값 힙 - Python

MAYMIN 2021. 8. 1. 13:25
728x90
SMALL
import sys,heapq

input = sys.stdin.readline
n = int(input())
heap = []
for _ in range(n):
    num = int(input())
    if num==0:
        if len(heap)==0:
            print(0)
        else:
            min = heapq.heappop(heap)[1]
            print(min)
    else:
        heapq.heappush(heap,(abs(num),num))
728x90
LIST

'취준시절 > 백준' 카테고리의 다른 글

[백준 4673] 셀프 넘버 - Python  (0) 2021.08.03
[백준 1715] 카드 정렬하기 - Python  (0) 2021.08.01
[백준 1927] 최소 힙 - Python  (0) 2021.08.01
[백준 11279] 최대 힙 - Python  (0) 2021.08.01
[백준 2164] 카드2 - Python  (0) 2021.07.31