[백준 1927] 최소 힙_Python

코뉴·2021년 2월 13일
0

백준🍳

목록 보기
34/149
post-thumbnail

https://www.acmicpc.net/problem/1927

🥚문제


🥚입력/출력


🍳코드

import sys
import heapq

input = sys.stdin.readline

n = int(input())
q = []
for _ in range(n):
    x = int(input())
    if x == 0:
        if len(q) > 0:
            print(heapq.heappop(q))
        else:
            print(0)
    else:
        heapq.heappush(q, x)

🧂아이디어

  • 최소 힙 써보기 문제
profile
코뉴의 도딩기록

0개의 댓글