# 더 맵게 - 프로그래머스

더 맵게 - 프로그래머스

import heapq

def solution(scoville, K):
    answer = 0
    heap = []
    for i in scoville:
        heapq.heappush(heap, i)
    while True:
        if len(heap) == 1:
            break
        heapq.heappush(heap, heapq.heappop(heap) + heapq.heappop(heap) * 2)
        answer += 1
        if heap[0] >= K:
            return answer
    return -1