what should i do when my coins are over in problem without reaching ans and should i abort if i get -1?

you have 1000 coins in the beginning and u have to find the answer in these 1000 coins only !!! u wont get more than 1000 coins in any test case. We can solve all the test cases with the given constraints . if u need more than 1000 coins to solve then simply change the way you are thinking , change your approach for this problem.

Test case are very weak i got 100 but still my code contains bugs which I debug latter

Think more mathematically >>>>>

have a closer look at the ways you spend your coins , once you find where to save the coins , the problem is more simpler than it seems …

Best Wishes.

If you are running out of coins or getting -1 as response then rethink your approach.

isn’t it simple binary search? , i am getting few wrong answer by this approach