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

codetrix2

#1

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…!!


#2

Take a look at this solution http://www.codechef.com/viewsolution/5460578


#3

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…


#4

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…


#5

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:


#6

okay… cool… :slight_smile: