Please do mention the mistake
Tried the Problem using Binary Search, Loop is not stopping, COMPILATION ERROR!
Actually you were storing the index value in ans instead of the value of the coin in that index but because of that as the index is only from 0 to 9 then you might have case where the index is 0 and the loop will not be able to terminate.
money = money - ans( in this case 0)
the above condition will result in a TLE .
The code should be something like this : https://ide.codingblocks.com/s/313597
Also , if you have any query you can ask me regarding this question . and if you think the doubt is resolved mark the doubt as resolved and give ratings as to how helpful my explation was to you . it will help me in boosting my rating as i am new TA here . xD . Have a good day ! 