
μ°μ μμ ν μκ³ λ¦¬μ¦μ΄λΌκ³ λ νλ ν(heap) ν μκ³ λ¦¬μ¦μ ꡬνμ μ 곡νλ λΌμ΄λΈλ¬λ¦¬
pythonμμ defaultλ min_heap
import heapq
test_heap =[]
heapq.heapify(test_heap)
from heapq import *
test_heap =[]
heapify(test_heap)
ν λΆλ³μ±μ μ μ§νλ©΄μ, itemκ°μ heapμΌλ‘ νΈμ
heapq.heappush(heap, item)
ν λΆλ³μ±μ μ μ§νλ©΄μ, heapμμ κ°μ₯ μμ νλͺ©μ ννκ³ λ°ν
heapq.heappop(heap)
IndexErrorκ° λ°μ리μ€νΈ xλ₯Ό O(N)μκ°μΌλ‘ μ μ리μμ νμΌλ‘ λ³ν
heapq.heapify(x)
πPython Docs: heapq
https://www.acmicpc.net/board/view/119137