← 返回 snowflake 的题目列表Minimum Value Weight
类型:online_judge
Given an array of chocolate weights weights and an integer d, determine the minimum total weight of chocolates that can be retained after d days. Each day, you can choose one chocolate, consume half of it (floored), and keep the remaining portion. You can only choose from previously retained chocolates from the prior day. The constraints are as follows:
1 <= n <= 10^5 (n is the length of weights)
1 <= d <= 2*10^9
Implement a function findMinWeight that takes weights (an integer array) and d (an integer for the number of days) as parameters. Return the minimum total weight of chocolates after d days.
Example Input:
weights = [10, 20, 30]
d = 4
Example Output:
15
Example
Input
10
20
30
4