import sys
import heapq
input = sys.stdin.readline
n = int(input())
h = []
for i in range(n):
x = int(input())
if x==0:
# 리스트가 비어있으면 if not 조건이 True가 됨
if not h:
print(0)
else:
print(heapq.heappop(h))
else:
heapq.heappush(h,x)
'[BOJ] - Python' 카테고리의 다른 글
[백준] 1931 : 회의실 배정 python (0) | 2023.08.12 |
---|---|
[백준] 11047 : 동전 0 python (0) | 2023.08.12 |
[백준] 1991 : 트리 순회 python (0) | 2023.08.10 |
[백준] 11279 : 최대 힙 python (0) | 2023.08.10 |
[백준] 11557 : Yangjojang of The Year python (0) | 2023.04.09 |