Problem · Array
Minimum Processing Speed with Multiple Riders
Learn this problemProblem statement
Assign an ordered sequence of indivisible order workloads to at most riders riders. Each rider receives one contiguous subsequence, and every rider has at most hoursPerRider whole hours.
At a shared positive integer speed k, workload w takes ceil(w / k) hours. A rider processes assigned orders in order, and unused time in an order's final hour is lost.
Return the minimum speed for which a left-to-right contiguous assignment uses at most riders riders.
Function
minimumMultiRiderSpeed(workloads: int[], riders: int, hoursPerRider: int) → intExamples
Example 1
workloads = [3,6,7,11]riders = 2hoursPerRider = 4return = 6At speed 6 the required hours are [1,1,2,2]. One rider takes the first three orders in four hours and the other takes the last order. Speed 5 needs three contiguous groups.
Example 2
workloads = [8,8,8]riders = 3hoursPerRider = 1return = 8Each rider must finish one order in one hour.
Constraints
workloadsis non-empty and every workload is positive.ridersandhoursPerRiderare positive.ridersdoes not exceed the number of workloads.riders * hoursPerRideris at least the number of workloads, so a feasible speed always exists.