Problem
Process Scheduling
A multiprocessor system contains several processors. ability[i] represents the number of processes the i-th processor can schedule in one second.
In each second, choose any one processor and use it to schedule up to its current ability. After the processor is used, its ability becomes floor(ability / 2).
Given the processor abilities and the total number of processes that must be scheduled, return the minimum time in seconds required to schedule all processes.
Examples
01 · Example 1
ability = [3,1,7,2,4] processes = 15 return = 4
Use abilities 7, 4, 3, and 1 over four seconds. The remaining process count becomes 8, then 4, then 1, then 0.
02 · Example 2
ability = [5,3] processes = 8 return = 2
Use the processor with ability 5, then the processor with ability 3.
Constraints
1 <= ability.length <= 10^51 <= ability[i] <= 10^61 <= processes <= 10^12- It is guaranteed that the processes can be scheduled using the given system.
More Blackrock problems
public int minimumSchedulingTime(int[] ability, long processes) {
// write your code here
}ability[3,1,7,2,4]
processes15
expected4
sign in to submit