Book allocation problem

whats wrong in my code can you please check.it works fine for custom input https://ide.codingblocks.com/s/165134
but is giving wrong answer while submitting the code

I have edited your code, try to submit now,