https://www.acmicpc.net/problem/1927
import heapq, sys
input = sys.stdin.readline
n = int(input())
heap = []
for _ in range(n):
x = int(input())
if x == 0:
print(heapq.heappop(heap)) if heap else print(0)
else:
heapq.heappush(heap, x)
'백준' 카테고리의 다른 글
백준 20006. 랭킹전 대기열 (0) | 2025.02.06 |
---|---|
백준 20055. 컨테이너 벨트 위의 로봇 (0) | 2025.02.03 |
백준 12919. A와 B 2 (0) | 2025.02.02 |
백준 20310. 타노스 (0) | 2025.02.02 |
백준 9328. 열쇠 (0) | 2025.02.02 |