1962. Remove Stones to Minimize the Total

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1962

class Solution:
    def minStoneSum(self, piles: List[int], k: int) -> int:
        pq = [-x for x in piles]
        heapify(pq)
        for _ in range(k):
            heapreplace(pq, pq[0] // 2)
        return -sum(pq)