힙
import heapq
def solution(scoville, K):
answer = 0
heap = scoville
heapq.heapify(heap)
while len(heap) >= 2:
if heap[0] >= K or len(heap) < 2:
break
min_hot = heapq.heappop(heap)
min_next_hot = heapq.heappop(heap)
heapq.heappush(heap, min_hot + min_next_hot * 2)
answer +=1
if heap[0] < K:
return -1
else:
return answer