Minimum Total Weight
There are n chocolates and the weight of the chocolates is given as an array of integers weights[n], where weights[i] denote the weight of the ith chocolate. Every day, one can pick one chocolate, eat half of it, and put the remaining half back. Find the minimum possible total weight of the remaining chocolates after d days. Note that one can eat the same chocolate multiple times. The weight of the part eaten can be calculated as floor(weights[i]/2).
Function Description
Complete the function findMinWeight in the editor below.
findMinWeight has the following parameters:
int weights[n]: an array of integers representing weights of chocolates, indexed0ton-1int d: an integer representing the number of days
Returns
int: the minimum total weight of chocolates after d days.
\U0001fae7A heartfelt thank you to A ⋆°
Constraints:
1 ≤ n ≤ 10^51 ≤ weights[i] ≤ 10^4(where0 ≤ i < n)1 ≤ d ≤ 2*10^6
Example
Unlock to view complete problem details
and practice with sample input/output
View Test Cases & Run Code requires membership
