class Solution { public int minStoneSum(int[] piles, int k) { PriorityQueue<Integer> priorityQueue = new PriorityQueue<>((num1, num2) -> num2 - num1); for (int pile : piles) { priorityQueue.offer(pile); } for (int i = 0; i < k; i++) { priorityQueue.offer((priorityQueue.poll() + 1) >> 1); } int sum = 0; for (Integer num : priorityQueue) { sum += num; } return sum; } }