My all cases are showing wrong ans

https://ide.codingblocks.com/s/571691 all my test cases are wrong but my sample case is passing . can you please have a look where i am doing it wrong

you have to print ans of every testcase in newline
use endl

cout<<ans<<endl;

still all test cases are showing wrong ans

s should be equal to arr[n-1] not arr[0]
because some student has to read atleast arr[n-1] pages (max pages)

Modified code

but still it shouldn’t make a difference as binary search will take care of it by finding max pages possible