Minimum Time to Repair Cars
You are given an integer array ranks representing the ranks of some mechanics. ranks[i] is the rank of the i^th mechanic. A mechanic with a rank r can repair n cars in r * n^2 minutes.
You are also given an integer cars representing the total number of cars waiting in the garage to be repaired.
Return the minimum time taken to repair all the cars.
Note: All the mechanics can repair the cars simultaneously.
Example 1
Input
ranks = [4,2,3,1], cars = 10Output
16Assigning 2, 2, 2, and 4 cars to the mechanics takes at most 16 minutes, and it can be proved that fewer than 16 minutes is impossible.
Example 2
Input
ranks = [5,1,8], cars = 6Output
16Assigning 1, 4, and 1 cars to the mechanics takes at most 16 minutes, and it can be proved that fewer than 16 minutes is impossible.
Constraints
- 1 <= ranks.length <= 10^5
- 1 <= ranks[i] <= 100
- 1 <= cars <= 10^6