최소힙

이세진·2022년 4월 15일
0

코테준비

목록 보기
41/87

생성일: 2022년 1월 29일 오후 6:11

구현 코드

# 최소힙
import sys
import heapq
sys.stdin = open("input.txt", "rt")

heap = []

while True:
    num = int(input())
    if num == -1:
        break
    elif num == 0:
        print(heapq.heappop(heap))
    else:
        heapq.heappush(heap, num)
profile
나중은 결코 오지 않는다.

0개의 댓글

Powered by GraphCDN, the GraphQL CDN