551. Minimum Time to Repair Cars

HardBinary SearchBinary Search on AnswerMath

Mechanics have ranks; a mechanic of rank r can repair n cars in r * n^2 minutes. Given the ranks of all mechanics and a number of cars, return the minimum time (in minutes) to repair all the cars, with mechanics working in parallel. Input: '[ranks], cars'.

Input: '[ranks], cars'.

Output: Integer — the minimum time in minutes.

Examples

Example 1
Input: [4,2,3,1], 10
Output: 16
Explanation: In 16 minutes the mechanics together repair 10 cars.
Example 2
Input: [5], 1
Output: 5
Explanation: One mechanic, one car.
Example 3
Input: [1,1,1], 5
Output: 4
Explanation: Three rank-1 mechanics.

Constraints

Asked by

DeloitteGoogleMicrosoftAmazonMeta
Solve this problem in the editor →