코딩테스트/백준 (python)
백준 / 1927번 / 최소 힙 / python 파이썬
seulll
2024. 11. 22. 22:33
문제 : https://www.acmicpc.net/problem/1927
나의 풀이
import sys
import heapq
input = sys.stdin.readline
n = int(input())
heap = []
for i in range(n):
x = int(input())
if x == 0:
if len(heap):
print(heapq.heappop(heap))
else:
print(0)
else:
heapq.heappush(heap, x)
시간 초과가 발생해서 sys 모듈을 사용하여 재제출하니 통과하였다.