Please, correct me if I am wrong. In the worst case, first of all our centipede will take 40 right slippers (40slip * 2sec) After that it will take all of the remaining right slippers ((rightSlippers-40) * 2sec) Then, because there are no right slippers left, it will take 40 left slippers(40slip * 1sec) And finally take remaining left slippers and throw them away ((leftSlippers-40) * 2sec) I guess I didn't understand the task correctly, may someone explain it to me?
I guess I should of have searched a little more, I found what is the case.
If any of you are interested the solution is that there may be another situation where we have >40 left slippers, so first we take 39 right ones, then 40 left ones, throw remaining lefts away and take our last right. Depending on which one is longer, you may use this solution or the one I posted before.
P.S. of course you don't have to throw away the remaining slippers once all legs are dressed, my bad.