hours hours left before an exam and must read every chapter of the notes: chapter i has chapters[i] pages. They pick a fixed pace, a whole number of pages per hour.
Each hour they work on one chapter: if at least that many pages are left in it, they read exactly that many; if fewer are left, they finish the chapter and rest for the remainder of the hour. They cannot start another chapter within the same hour.
The student wants to read as slowly as possible and still get through everything. Return the minimum pace that lets them finish within hours hours.chapters=[12, 5, 9], hours=6 → 5
At 5 pages per hour: 12 pages take 3 hours, 5 take 1, 9 take 2, for 6 in total. At 4 per hour it would be 3 + 2 + 3 = 8 hours, which is too many.
chapters=[20, 7], hours=2 → 20
There are as many hours as chapters, so each one must take a single hour: the pace must be at least the longest chapter.
chapters=[3, 3, 3], hours=100 → 1
chapters=[12, 5, 9], hours=6
5
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.