You are given a list of integers weights, where weights[i] is the weight of the i-th item, and an integer operations.
In one halving operation, you choose any item and replace its weight w with floor(w / 2), i.e. integer division that rounds down. The same item can be chosen in more than one operation.
Perform exactly operations halving operations to minimize the total weight of all items, and return this minimum total weight.
long minimizeTotalWeight(List<Integer> weights, int operations)
weights: weights[i] is the current weight of the i-th item.operations: the exact number of halving operations to perform.1 ≤ weights.size() ≤ 100,0001 ≤ weights[i] ≤ 1,000,000,0001 ≤ operations ≤ 100,000minimizeTotalWeight(weights = [4, 9, 16, 3], operations = 3)
Output: 15
[4, 9, 8, 3][4, 4, 8, 3][4, 4, 4, 3]minimizeTotalWeight(weights = [7], operations = 5)
Output: 0
minimizeTotalWeight(weights = [25, 30, 11], operations = 4)
Output: 24
[25, 15, 11][12, 15, 11][12, 7, 11][6, 7, 11]