You have an array of integers and can perform k operations on it. You take any number at each operation, divide it by 2, and put its ceiling value in the array. The goal is to minimize the total array sum after k operations.
Input
An array of integers
An integer k representing the number of operations
Output
The minimum total array sum after k operations
Example 1:
Input:[[10,9,2,5,3,7,101,18],3]
Output:32
Constraints:
1 <= n <= 100
1 <= k <= 100
1 <= array values <= 1000
solution.cpp
Loading...
Run code to see test results
00:00 / 69:42
Minimize Array Sum After K Operations IIT BHU
MediumMed•394 views
Problem
You have an array of integers and can perform k operations on it. You take any number at each operation, divide it by 2, and put its ceiling value in the array. The goal is to minimize the total array sum after k operations.
Input
An array of integers
An integer k representing the number of operations