Step 1: Set low = max book pages = 500, high = sum of all pages = 1500
low=500, high=1500
Why: Minimum max pages can't be less than largest book; maximum is sum of all pages
Step 2: Calculate mid = (500 + 1500) // 2 = 1000; check if allocation possible with max 1000 pages
Trying max_pages=1000
Why: Mid is our guess for max pages per student
Step 3: Allocate books: Student 1 gets 100+200+300=600 pages, Student 2 gets 400 pages, Student 3 gets 500 pages
Allocation possible with max_pages=1000
Why: All books allocated within max_pages=1000
Step 4: Since allocation possible, try smaller max: high = mid - 1 = 999
low=500, high=999
Why: Try to find smaller max pages
Step 5: Calculate mid = (500 + 999) // 2 = 749; check allocation with max 749
Trying max_pages=749
Why: New guess for max pages
Step 6: Allocate books: Student 1 gets 100+200=300 pages, Student 2 gets 300 pages, Student 3 gets 400+500=900 pages (exceeds 749)
Allocation not possible with max_pages=749
Why: Last student exceeds max_pages, allocation fails
Step 7: Since allocation failed, increase low: low = mid + 1 = 750
low=750, high=999
Why: Need larger max pages to allocate
Step 8: Calculate mid = (750 + 999) // 2 = 874; check allocation with max 874
Trying max_pages=874
Why: New guess for max pages
Step 9: Allocate books: Student 1 gets 100+200+300=600 pages, Student 2 gets 400 pages, Student 3 gets 500 pages
Allocation possible with max_pages=874
Why: All books allocated within max_pages=874
Step 10: Since allocation possible, try smaller max: high = mid - 1 = 873
low=750, high=873
Why: Try to find smaller max pages
Step 11: Calculate mid = (750 + 873) // 2 = 811; check allocation with max 811
Trying max_pages=811
Why: New guess for max pages
Step 12: Allocate books: Student 1 gets 100+200+300=600 pages, Student 2 gets 400 pages, Student 3 gets 500 pages
Allocation possible with max_pages=811
Why: All books allocated within max_pages=811
Step 13: Since allocation possible, try smaller max: high = mid - 1 = 810
low=750, high=810
Why: Try to find smaller max pages
Step 14: Calculate mid = (750 + 810) // 2 = 780; check allocation with max 780
Trying max_pages=780
Why: New guess for max pages
Step 15: Allocate books: Student 1 gets 100+200+300=600 pages, Student 2 gets 400 pages, Student 3 gets 500 pages
Allocation possible with max_pages=780
Why: All books allocated within max_pages=780
Step 16: Since allocation possible, try smaller max: high = mid - 1 = 779
low=750, high=779
Why: Try to find smaller max pages
Step 17: Calculate mid = (750 + 779) // 2 = 764; check allocation with max 764
Trying max_pages=764
Why: New guess for max pages
Step 18: Allocate books: Student 1 gets 100+200+300=600 pages, Student 2 gets 400 pages, Student 3 gets 500 pages
Allocation possible with max_pages=764
Why: All books allocated within max_pages=764
Step 19: Since allocation possible, try smaller max: high = mid - 1 = 763
low=750, high=763
Why: Try to find smaller max pages
Step 20: Calculate mid = (750 + 763) // 2 = 756; check allocation with max 756
Trying max_pages=756
Why: New guess for max pages
Step 21: Allocate books: Student 1 gets 100+200=300 pages, Student 2 gets 300 pages, Student 3 gets 400+500=900 pages (exceeds 756)
Allocation not possible with max_pages=756
Why: Last student exceeds max_pages, allocation fails
Step 22: Since allocation failed, increase low: low = mid + 1 = 757
low=757, high=763
Why: Need larger max pages to allocate
Step 23: Calculate mid = (757 + 763) // 2 = 760; check allocation with max 760
Trying max_pages=760
Why: New guess for max pages
Step 24: Allocate books: Student 1 gets 100+200+300=600 pages, Student 2 gets 400 pages, Student 3 gets 500 pages
Allocation possible with max_pages=760
Why: All books allocated within max_pages=760
Step 25: Since allocation possible, try smaller max: high = mid - 1 = 759
low=757, high=759
Why: Try to find smaller max pages
Step 26: Calculate mid = (757 + 759) // 2 = 758; check allocation with max 758
Trying max_pages=758
Why: New guess for max pages
Step 27: Allocate books: Student 1 gets 100+200=300 pages, Student 2 gets 300 pages, Student 3 gets 400+500=900 pages (exceeds 758)
Allocation not possible with max_pages=758
Why: Last student exceeds max_pages, allocation fails
Step 28: Since allocation failed, increase low: low = mid + 1 = 759
low=759, high=759
Why: Need larger max pages to allocate
Step 29: Calculate mid = (759 + 759) // 2 = 759; check allocation with max 759
Trying max_pages=759
Why: New guess for max pages
Step 30: Allocate books: Student 1 gets 100+200=300 pages, Student 2 gets 300 pages, Student 3 gets 400+500=900 pages (exceeds 759)
Allocation not possible with max_pages=759
Why: Last student exceeds max_pages, allocation fails
Step 31: Since allocation failed, increase low: low = mid + 1 = 760
low=760, high=759
Why: Need larger max pages to allocate
Result: Final allocation max pages = 760
Books: [100] -> [200] -> [300] -> [400] -> [500]
Students: 3
Allocation: Student 1: 100+200+300=600, Student 2: 400, Student 3: 500
Max pages = 760