n dials, and dial i is set to values[i]. In one step you can turn any dial up or down by 1; a step of dial i costs prices[i].
All dials must be set to the same value. Return the minimum total cost.values=[4, 10, 7], prices=[1, 1, 5] → 6
Moving the expensive third dial does not pay off, so set everything to 7: raise the first by 3 (cost 3) and lower the second by 3 (cost 3), 6 in total.
values=[5, 5], prices=[2, 9] → 0
The values already match.
values=[1, 8, 3, 6], prices=[3, 2, 2, 4] → 25
values) = len(prices)values[i], prices[i] ≤ 10⁶values=[4, 10, 7], prices=[1, 1, 5]
6
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.