Can anyone explain me how i can solve this question
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. sIPh8C - Online C++ Compiler & Debugging Tool - Ideone.com
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.