Probelm was pretty interesting but i am still unable to figure out the algorithm to solve this problem. Please can anyone help me to figure out the algorithm used to solve this problem
Also can any one please tell me how have they figured out that xyz algorithm should be used to solve this problem where by reading the problem statement it seems that one has to sort the input in descending order and then add the first ‘k’ variables and have to print the sum.
My Solution: link:http://www.codechef.com/viewsolution/5459853
Most important part of that problem was line: The robo-arm is capable of picking up K consecutive toys
So that is what brought up the idea for the solution…
First thing that clicked my mind was to sum through every K consecutive elements starting from i=0 to i=n, but that would have resulted in TLE…
So the next thing that came in mind was to keep the sum of all previous elements so that we don’t have to loop through every K sets, which resulted in the solution.
If you are still unable to understand the solution, do ask, I’ll explain in more detail…