문제 : 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 모듈을 사용하여 재제출하니 통과하였다.
'코딩테스트 > 백준 (python)' 카테고리의 다른 글
백준 / 1987번 / 알파벳 / python 파이썬 (0) | 2024.12.02 |
---|---|
백준 / 16953번 / A → B / python 파이썬 (0) | 2024.11.25 |
백준 / 1766번 / 문제집 / python 파이썬 (0) | 2024.11.17 |
백준 / 12865번 / 평범한 배낭 / python 파이썬 (1) | 2024.11.12 |
백준 / 2156번 / 포도주 시식 / python 파이썬 (0) | 2024.11.07 |