Job Scheduling
Learn this problemProblem statement
There are m jobs to schedule on n processors. A schedule is balanced if the difference between the number of jobs scheduled on any two neighboring processors does not exceed 1.
The kth processor is the most efficient, and thus, the maximum number of jobs should be scheduled on that processor. Find the maximum number of jobs that can be scheduled on the kth processor, such that the overall schedule remains balanced.
Note: Each processor must have at least one job scheduled.
Function
getMaximumJobs(n: int, m: int, k: int) → int
Complete the function getMaximumJobs in the editor.
getMaximumJobs has the following parameters:
int n: the number of processorsint m: the number of jobsint k: the 1-based index of the most efficient processor
Returns
int: the maximum number of jobs that can be scheduled on the kth processor maintaining a balanced schedule
Examples
Example 1
n = 5m = 11k = 5return = 4
Given n = 5, m = 11, k = 5.
One optimal job schedule is [1, 1, 2, 3, 4].
Example 2
n = 5m = 11k = 3return = 3
Constraints
1 ≤ n ≤ 105n ≤ m ≤ 1091 ≤ k ≤ n