Step 1: Set low to max book pages (500), high to sum of all pages (1500), start binary search
low=500, high=1500
Why: Minimum max pages can't be less than largest book, max can't be more than total pages
Step 2: Check mid = (500+1500)/2 = 1000, try allocation with max pages 1000
Try allocation with max_pages=1000
Why: Test if 1000 pages max per student is possible
Step 3: Allocate books: Student1 gets 100+200+300=600 ≤1000, Student2 gets 400 ≤1000, Student3 gets 500 ≤1000
Allocation possible with max_pages=1000
Why: All students can get books without exceeding 1000 pages
Step 4: Since allocation possible, try smaller max: high = mid = 1000
low=500, high=1000
Why: Try to find smaller max pages
Step 5: Check mid = (500+1000)/2 = 750, try allocation with max pages 750
Try allocation with max_pages=750
Why: Test if 750 pages max per student is possible
Step 6: Allocate books: Student1 gets 100+200+300=600 ≤750, Student2 gets 400 ≤750, Student3 gets 500 ≤750
Allocation possible with max_pages=750
Why: All students can get books without exceeding 750 pages
Step 7: Since allocation possible, try smaller max: high = mid = 750
low=500, high=750
Why: Try to find smaller max pages
Step 8: Check mid = (500+750)/2 = 625, try allocation with max pages 625
Try allocation with max_pages=625
Why: Test if 625 pages max per student is possible
Step 9: Allocate books: Student1 gets 100+200+300=600 ≤625, Student2 gets 400 ≤625, Student3 gets 500 ≤625
Allocation possible with max_pages=625
Why: All students can get books without exceeding 625 pages
Step 10: Since allocation possible, try smaller max: high = mid = 625
low=500, high=625
Why: Try to find smaller max pages
Step 11: Check mid = (500+625)/2 = 562, try allocation with max pages 562
Try allocation with max_pages=562
Why: Test if 562 pages max per student is possible
Step 12: Allocate books: Student1 gets 100+200=300 ≤562, Student2 gets 300+400=700 >562 (fail)
Allocation not possible with max_pages=562
Why: Second student exceeds max pages, allocation fails
Step 13: Since allocation failed, increase low: low = mid + 1 = 563
low=563, high=625
Why: Need larger max pages to allocate
Step 14: Check mid = (563+625)/2 = 594, try allocation with max pages 594
Try allocation with max_pages=594
Why: Test if 594 pages max per student is possible
Step 15: Allocate books: Student1 gets 100+200=300 ≤594, Student2 gets 300+400=700 >594 (fail)
Allocation not possible with max_pages=594
Why: Second student exceeds max pages, allocation fails
Step 16: Since allocation failed, increase low: low = mid + 1 = 595
low=595, high=625
Why: Need larger max pages to allocate
Step 17: Check mid = (595+625)/2 = 610, try allocation with max pages 610
Try allocation with max_pages=610
Why: Test if 610 pages max per student is possible
Step 18: Allocate books: Student1 gets 100+200+300=600 ≤610, Student2 gets 400 ≤610, Student3 gets 500 ≤610
Allocation possible with max_pages=610
Why: All students can get books without exceeding 610 pages
Step 19: Since allocation possible, try smaller max: high = mid = 610
low=595, high=610
Why: Try to find smaller max pages
Step 20: Check mid = (595+610)/2 = 602, try allocation with max pages 602
Try allocation with max_pages=602
Why: Test if 602 pages max per student is possible
Step 21: Allocate books: Student1 gets 100+200+300=600 ≤602, Student2 gets 400 ≤602, Student3 gets 500 ≤602
Allocation possible with max_pages=602
Why: All students can get books without exceeding 602 pages
Step 22: Since allocation possible, try smaller max: high = mid = 602
low=595, high=602
Why: Try to find smaller max pages
Step 23: Check mid = (595+602)/2 = 598, try allocation with max pages 598
Try allocation with max_pages=598
Why: Test if 598 pages max per student is possible
Step 24: Allocate books: Student1 gets 100+200=300 ≤598, Student2 gets 300+400=700 >598 (fail)
Allocation not possible with max_pages=598
Why: Second student exceeds max pages, allocation fails
Step 25: Since allocation failed, increase low: low = mid + 1 = 599
low=599, high=602
Why: Need larger max pages to allocate
Step 26: Check mid = (599+602)/2 = 600, try allocation with max pages 600
Try allocation with max_pages=600
Why: Test if 600 pages max per student is possible
Step 27: Allocate books: Student1 gets 100+200+300=600 ≤600, Student2 gets 400 ≤600, Student3 gets 500 ≤600
Allocation possible with max_pages=600
Why: All students can get books without exceeding 600 pages
Step 28: Since allocation possible, try smaller max: high = mid = 600
low=599, high=600
Why: Try to find smaller max pages
Step 29: Check mid = (599+600)/2 = 599, try allocation with max pages 599
Try allocation with max_pages=599
Why: Test if 599 pages max per student is possible
Step 30: Allocate books: Student1 gets 100+200=300 ≤599, Student2 gets 300+400=700 >599 (fail)
Allocation not possible with max_pages=599
Why: Second student exceeds max pages, allocation fails
Step 31: Since allocation failed, increase low: low = mid + 1 = 600
low=600, high=600
Why: Low meets high, search ends
Result: Final allocation max pages = 600
Books allocated as:
Student1: 100 -> 200 -> 300 -> null
Student2: 400 -> null
Student3: 500 -> null