Algorithm/[BOJ] - Python
[백준] 1927 : 최소 힙 python
Codew
2023. 8. 10. 18:26
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)