Ctrl K

Sharing Jobs Fairly

Hard
You have a list of jobs jobs, where job i takes jobs[i] units of time. Hand the jobs out to workers workers so that each job goes to exactly one of them. A worker's load is the total time of all their jobs. Assign the jobs so that the largest load among the workers is as small as possible, and return that load.
Example 1
jobs=[5, 3, 2, 4], workers=2 → 7

One worker takes 5 and 2, the other takes 3 and 4, so both are busy for 7. That is the best possible, since the total work is 14.

Example 2
jobs=[9, 1, 1], workers=3 → 9

Everyone gets one job, and the longest one takes 9.

Example 3
jobs=[6, 6, 6, 6], workers=3 → 12

Four jobs for three workers means someone gets two of them, which is 12.

Constraints
  • 1 ≤ workers ≤ len(jobs) ≤ 12
  • 1 ≤ jobs[i] ≤ 10⁷
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSettle Up in the Fewest Transfers HardSquare-Sum Chains HardBest Word Set From Tiles HardOrders of Identical Parts HardSquare Frame From Sticks Medium
loading Python…
Input
jobs=[5, 3, 2, 4], workers=2
Expected
7

Run checks the first 3 tests in your browser. Submit checks all 113 tests on the server, hidden ones included.