Slowest Safe Print Speed
mediumA print shop has a stack of jobs: jobs[i] is the page count of job i. The printer runs at a fixed speed of s pages per hour, but it can only work on one job per hour — if a job (or its remainder) finishes early, the rest of that hour is lost waiting for the operator.
The shop closes in hours hours. Return the minimum integer speed s that finishes every job in time. Each job j takes ceil(jobs[j] / s) hours. It's guaranteed hours >= len(jobs), so a fast-enough speed always exists.
Example 1
in jobs = [3, 6, 7, 11], hours = 8
out 4
At speed 4: 1 + 2 + 2 + 3 = 8 hours. Speed 3 needs 1 + 2 + 3 + 4 = 10.
Example 2
in jobs = [30, 11, 23, 4, 20], hours = 5
out 30
One hour per job — speed must cover the biggest job whole.
Constraints
- · 1 <= len(jobs) <= 2000
- · len(jobs) <= hours <= 10^6
- · 1 <= jobs[i] <= 10^6
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.