Ctrl K

Cloning Builders

Hard
There is a set of jobs to do: jobs[i] is how many time units the i-th job takes. Each job is done start to finish by a single builder, who then goes home. At the start there is one builder. Any idle builder may clone instead of working: after clone_cost time units one builder becomes two. Several builders can clone at the same time, and that still takes clone_cost. Return the earliest time by which all the jobs can be finished.
Example 1
jobs=[6], clone_cost=3 → 6

One builder and one job: no need to clone, 6 time units.

Example 2
jobs=[2, 9, 4], clone_cost=2 → 11

Clone (2): one builder takes the job of 9 and finishes at 11. The other clones again (done at 4), and the pair handle 2 and 4, finishing at 8. The answer is 11.

Example 3
jobs=[1, 1, 1, 1], clone_cost=5 → 11

Four builders are needed: two cloning rounds of 5 each, then 1 for the work, 11 in total.

Constraints
  • 1 ≤ len(jobs) ≤ 10⁵
  • 1 ≤ jobs[i] ≤ 10⁵
  • 1 ≤ clone_cost ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPrices That Fade With Each Sale MediumSame Prizes, Different Tastes MediumA Crew Levels a Hill MediumGrowing Capital Project by Project HardMost Orders by Their Deadlines Hard
loading Python…
Input
jobs=[6], clone_cost=3
Expected
6

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