Question: 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

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 i th 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 Example chocolates 30 20 25 d 4 Day Weight of the chocolate picked Weight eaten Remaining weight Result 1 20 10 10 30 10 25 2 25 12 13 30 10 13 3 30 15 15 15 10 13 4 15 7 8 8 10 13 The total weight of chocolates on day 4 is 8 10 13 31 which is the minimum possible weight after 4 days 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 indexed 0 to n 1 int d an integer representing the number of days Returns int the minimum total weight of chocolates after d days Constraints where Input Format for Custom Testing The first line contains an integer n denoting the number of elements in weights Each line of the n subsequent lines where contains an integer describing weights i The last line contains an integer d denoting the number of days Sample Input for Custom Testing Sample Case 0 weight 2 d 1 Sample Output 1 Explanation On day 1 eat the chocolate with weight 2 and the remaining weight becomes 1 The array becomes 1 with the sum of weights 1 Sample Case 1 weight 2 3 d 1 Sample Output 4 Explanation On day 1 pick either of the chocolates Chocolate with weight 2 weights 1 3 with a total weight of 4 Chocolate with weight 3 weights 2 2 with a total weight of 4 This is the full description of the problem based on the images you provided Can u use Java to solve the problem

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!