GREEDY ALGO deepak and his journey

Can someone please explain to me how to solve this problem?? I tried it but am not able to solve it. Please help!!!

Please post the link to the question here.