Book allocation problem

Code link

You are not printing answer of each testcase in new line.

after using endl in the output also it is not passing test cases

Check the way u are taking input. It should be cin>>arr[j]