精華區beta Marginalman 關於我們 聯絡資訊
2530. Maximal Score After Applying K Operations ## 思路 MaxHeap取k次 ## Code ```python class Solution: def maxKelements(self, nums: List[int], k: int) -> int: res = 0 max_heap = [] for num in nums: heapq.heappush(max_heap, -num) for _ in range(k): num = -heapq.heappop(max_heap) res += num heapq.heappush(max_heap, -ceil(num/3)) return res ``` -- https://i.imgur.com/kyBhy6o.jpeg -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 185.213.82.71 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1728870844.A.FCA.html
DJYOSHITAKA: 法國我 10/14 09:54
sustainer123: 別捲了 10/14 09:56
JIWP: 大師 10/14 09:57