Need help for problem Chef and robo-arm from Codetrix II

Problem :
Chef and robo-arm

Contest : Codetrix II

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.

Please Help…!

Thanks in Advance…!!

Take a look at this solution CodeChef: Practical coding for everyone

My Solution: link:CodeChef: Practical coding for everyone
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…

1 Like

i am sorry i am unable to understand why you code so?

Might be i am unable to understand the question but i am still unable to understand the logic behind your code… btw thanks for reply… but please help…

Missed word >>>consecutive<<<, forgot to read between the lines…

Thank You @prakhar8795…Thanks a lot, i was feeling so discouraged for not getting the problem statement.

I’ll try to attempt the problem again and i’ll ask for help if i don’t get your solution… Thanks… :slight_smile:

okay… cool… :slight_smile:

1 Like