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.jobs=[6], clone_cost=3 → 6
One builder and one job: no need to clone, 6 time units.
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.
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.
jobs=[6], clone_cost=3
6
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.