I am able to solve this for two student, but for more students ,How It will be solved?

My code link : https://ide.codingblocks.com/s/430413

I am able to solve this problem for two student, but for more nos. of students, I am not able to think how it will be solved?

In this i did not take input for student I assuming for two studnent and solving it

Thanks in Advance !!!

Hello @Deepak_nsit actually in this question we have to divide the book between the students with the certain pages to minimuse the maximum number of pages to the student and what is the logic in solving is this that as this is the question of binary search because we will divide our range and check if the dividing the books between students with these pages is possible or not.
first we will chosse the range and that will be from the book with the maximum pages to the sum of books with pages given:
As in this we are given with the students count so we have divided the range accordingly as if there is only one student available then you have to assign all the books to one student only so as this is the last option and the best case can be when the number of books is equal to the number of students in that we have chosen the book with the maximum pages as the student with the book with the maximum pages will completet the time.
and in that range we will check of trying to allocate the books to the student by dividing the range in halves.
if you still have any doubt you can ask here:
Happy Learning!!

1 Like