Reverse Maximisation Problem, I am unable to find the error in my code

https://www.codechef.com/viewsolution/24399545
Despite trying for a very long time, I am unable to find out the case for which my code is failing. Can anyone help me out?

try the case like - 19999. your code will give output18999.