Find the minimum time needed for a group of mechanics to repair all cars, where each mechanic's repair speed depends on their rank.
You are given an array of mechanic ranks and an integer cars. Each mechanic with rank r needs r * n^2 minutes to repair n cars.
All mechanics can work in parallel, and each mechanic may repair any nonnegative number of cars. Determine the minimum time required to repair at least cars cars in total.
Return the smallest integer time t such that the mechanics can collectively finish repairing all cars within t minutes.
ranks: an array of positive integers, where ranks[i] is the rank of mechanic icars: a positive integerThe exact platform signature may vary, but the core input is the ranks array and the number of cars.
cars cars.r can repair n cars in r * n^2 minutes.Example 1
Input
ranks = [4, 2, 3, 1], cars = 10
Output
16
Explanation
In 16 minutes, the mechanics can repair at least 10 cars in total. Any smaller time is not enough.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.