Problem 598391 · hard · Phase 05 Advanced Algorithms & Graphs

Balance Jobs Across Workers

backtracking · branch and bound · optimisation · partitioning

A print shop has jobs with durations jobs (in minutes) and k identical printers. Every job runs on exactly one printer, and a printer runs its jobs one after another. Return the smallest possible finishing time of the busiest printer, i.e. minimise the largest total assigned to one printer.

Examples

Input:  jobs = [3, 5, 2, 4], k = 2
Output: 7
Explanation: {3, 4} and {5, 2}.

Input:  jobs = [8], k = 3
Output: 8

Input:  jobs = [1, 2, 3, 4, 5, 6], k = 3
Output: 7
Explanation: {1, 6}, {2, 5}, {3, 4}.

Constraints

  • 1 <= len(jobs) <= 12, 1 <= k <= 12, 1 <= jobs[i] <= 10**4

Goals

  • Search assignments while keeping the best complete answer found so far
  • Cut branches that can no longer beat the best answer
Starting Python…