Book allocation problem

https://ide.codingblocks.com/s/53828

the code is running correctly for sample test case, but not working for test case. wht is the error?

Hi Yukti, since the output of every testcase should be printed in a new line, insert a newline in line number 66.
Also, you need to add one more base case in the for loop at line no. 7.
if(ar[i]>ans)
return false;
I have made these changes to your code, you can refer to it here.
https://ide.codingblocks.com/s/54022