Book Allocation

cant’t understand that part where bhaiya says "If there are M number of pages then one student can read atleast 40 pages " and It is given the number of pages of indivisual books .
so my doubt is how a person read atleast 40 pages he may read 10 pages which is the least number of pages in the array.
could anyone please clear my doubt .

The task is to assign books in such a way that the maximum number of pages assigned to a student is minimum.

The minimum possible answer cannot be less than maximum of given pages,
let n=5 and pages are 10,40,20,30 then answer cannot be less than 40,as atleast one of the students will be assigned that 40 page unit!

for 10 20 30 40
if one student read 10 pages then other has to read 90 so max no of pages read by student is 90 which is not minimum

this will be more clear after this
Example :

Input : pages[] = {12, 34, 67, 90}
m = 2(students)
Output : 113
Explanation:
There are 2 number of students. Books can be distributed
in following fashion :

  1. [12] and [34, 67, 90]
    Max number of pages is allocated to student
    2 with 34 + 67 + 90 = 191 pages
  2. [12, 34] and [67, 90]
    Max number of pages is allocated to student
    2 with 67 + 90 = 157 pages
  3. [12, 34, 67] and [90]
    Max number of pages is allocated to student
    1 with 12 + 34 + 67 = 113 pages

Of the 3 cases, Option 3 has the minimum pages = 113.

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course

1 Like