You are given an integer array jobs, where jobs[i] is the time it takes to complete job i, and an integer k, the number of workers. Each job must be assigned to exactly one worker. The working time of a worker is the sum of the times of all jobs assigned to that worker.
Find an assignment that makes the maximum working time over all workers as small as possible, and return that minimum possible maximum working time.
Function Signature
def minimum_time_required(jobs: list[int], k: int) -> int:
Rules
-
A job cannot be split between workers.
-
A worker may be given no jobs.
-
Return only the minimum possible maximum working time, not the assignment itself.
Constraints
-
1 <= k <= len(jobs) <= 12
-
1 <= jobs[i] <= 10^7
Examples
Input: jobs = [3, 2, 3], k = 3
Output: 3
Each worker takes one job, so the largest working time is 3. No assignment can do better, because some worker has to run a job that takes 3.
Input: jobs = [1, 2, 4, 7, 8], k = 2
Output: 11
One worker takes jobs 1, 2 and 8 (total 11) and the other takes 4 and 7 (total 11). The jobs add up to 22, so with two workers at least one of them carries 11 or more.
Input: jobs = [3, 3, 2, 2, 2], k = 2
Output: 6
The jobs add up to 12, so 6 is a lower bound, and the split {3, 3} and {2, 2, 2} reaches it. A split such as {3, 2, 2} and {3, 2} gives 7.