Written by
nodejs-style
on
on
[Baekjoon/Python] 1927번: 최소 힙 - 효과는 굉장했다!
[Baekjoon/Python] 1927번: 최소 힙 - 효과는 굉장했다!
반응형
알고리즘 분류
자료 구조
우선순위 큐
SOLUTION
import sys import heapq N = int(sys.stdin.readline()) heap = [] for _ in range(N): x = int(sys.stdin.readline()) if x > 0 : heapq.heappush(heap, x) elif x == 0: if heap == []: print(0) else: print(heap[0]) heapq.heappop(heap)
※ heapq 모듈
from http://thflgg133.tistory.com/140 by ccl(A) rewrite - 2021-12-25 16:00:52