harbor run -t openthoughts/tasktrove-exp-rpt-taco-v2-taco-4873harbor download openthoughts/tasktrove-exp-rpt-taco-v2-taco-4873Binod and his family live in Codingland, where they celebrate a festival called N-Halloween. The festival lasts for N consecutive days, during which Binod receives a certain amount of candies from his mother each day. Binod faces a dilemma: he may choose to take the candies he receives, but he will be sad if he collects candies on any day and, after giving some to his friend Pelu, he does not have at least X candies remaining at the end of that day.
Pelu, being a big fan of candies, immediately asks Binod for X candies on any day Binod collects candies. As a good friend, Binod always complies with Pelu’s request.
Your task is to find out the maximum number of candies Binod can collect throughout the festival days without feeling sad, after processing multiple queries about the minimum number of candies he wants to retain after giving some to Pelu.
For each query, output a single integer representing the maximum number of candies Binod can collect (for the given X) while ensuring he remains happy at the end of the festival.
5 2
4 6 5 8 7
1
2
30
30
In the first sample input, Binod can collect a maximum number of candies on each day as he will always retain at least 1 candy (after giving 1 to Pelu). Thus, the total is (4 + 6 + 5 + 8 + 7 = 30).
6 3
20 10 12 3 30 5
2
6
13
77
62
30
For the second input:
Place your solution in the /app/ directory.
Important: place your implementation at /app/solution.py so the verifier can run it.