I have a doubt related to this problem

how to do problem if i wan to find maximum pages that can be alloted ???
pls send copde if possible
i tried to do that but WAS unable to


my code ide its working fine here and offline complier but not working on coding block ide

Hello @Shubham800 i have corrected your code:

in this range should be from the book with the maximum number of pages to the sum of all the pages.
as you are given that the array given will be in ascending order os directly take the last element.
if you have any doubt you can ask here:
Happy Learning!!

i want to know why u have commented the line 51

Its done now thank u

but i want to know how to do ques that find the maximum pages that can ne alloted to a student such that whole books are alloted and no student is left to be alloted ???

i tried doing the ques i asked with agressive cow problem concept but it failing

Hello @Shubham800 i have given you the correct code there as well.

@Shubham800 see in this book allocation problem when we will find the particular answer then we will update that answer in the variable taken by you with name ‘ans’ and then we will keep in decrementing in our range through binary search if we are able to find valid answer in that range but if find that we are not able to distribute the book among students in the range then we will increment the start pointer.
in this way we are finding the correct answer and allocating books to all the student.
if you still have any doubt you can ask here:
Happy Learning!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.