i has a factor speed[i]: repairing m cars in a row takes them speed[i] · m² minutes. The smaller the factor, the faster the mechanic.
There are cars cars waiting. The mechanics work at the same time, and each car is repaired by exactly one of them. Return the smallest number of minutes in which all the cars can be repaired.speed=[3, 1, 2], cars=5 → 8
In 8 minutes the factor-1 mechanic manages 2 cars (1·2² = 4, while a third would need 9), the factor-2 one manages 2 (2·2² = 8) and the factor-3 one manages 1 (3·1² = 3). That makes 5. In 7 minutes it would be only 2 + 1 + 1 = 4.
speed=[2, 2], cars=4 → 8
Each mechanic takes two cars: 2·2² = 8 minutes.
speed=[7], cars=1 → 7
speed=[3, 1, 2], cars=5
8
Run checks the first 3 tests in your browser. Submit checks all 85 tests on the server, hidden ones included.