Bhallaladeva

Can anyone explain me how i can solve this question
https://www.codechef.com/ACMAMR15/problems/AMR15D

This was an adhoc problem. Simply sort the array and greedily pay for only the smaller cost only.

Here is a link to the AC solution during the contest from my team. http://ideone.com/sIPh8C

1 Like

Thanks a lot man. I dint greedily pay but traversed through the whole array thats the reason why i got TLE every time

Please mark the answer as correct.