i has an effort work[i] and a weight weight[i]. The queue must be split into contiguous batches without reordering: the first batch, the second, and so on.
Batch number b (counting from 1) that holds orders l through r costs
(work[0] + work[1] + … + work[r] + delay · b) · (weight[l] + … + weight[r]).
Note that the first factor adds up the effort of every order from the start of the queue to the end of the batch, not just the ones inside it.
Return the minimum total cost over all batches.work=[2, 3], weight=[1, 4], delay=2 → 35
One batch: (2 + 3 + 2·1)·(1 + 4) = 35. Two batches: (2 + 2·1)·1 + (2 + 3 + 2·2)·4 = 4 + 36 = 40. The answer is 35.
work=[5], weight=[3], delay=1 → 18
The only batch costs (5 + 1·1)·3 = 18.
work=[1, 9, 2, 2], weight=[6, 1, 1, 5], delay=3 → 164
work) ≤ 1000weight) = len(work)work[i], weight[i] ≤ 1000delay ≤ 1000work=[2, 3], weight=[1, 4], delay=2
35
Run checks the first 3 tests in your browser. Submit checks all 109 tests on the server, hidden ones included.