728x90
SMALL
import heapq
import sys
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)
print(min)
else:
heapq.heappush(heap,num)
728x90
LIST
'취준시절 > 백준' 카테고리의 다른 글
[백준 1715] 카드 정렬하기 - Python (0) | 2021.08.01 |
---|---|
[백준 11286] 절댓값 힙 - Python (0) | 2021.08.01 |
[백준 11279] 최대 힙 - Python (0) | 2021.08.01 |
[백준 2164] 카드2 - Python (0) | 2021.07.31 |
[백준 1158] 요세푸스 문제 - Python (0) | 2021.07.31 |