Imagine you're the manager of a busy auto repair shop with mechanics of different skill levels! ๐
You have an array of mechanics, where each mechanic has a rank representing their skill level. The higher the rank, the slower they work (counterintuitively). A mechanic with rank r takes r ร nยฒ minutes to repair n cars.
Your challenge: Given a total number of cars waiting to be repaired, determine the minimum time needed to repair all cars when all mechanics work simultaneously.
Key insight: Since mechanics work in parallel, the total time is determined by when the last car gets fixed. You need to optimally distribute the workload!
Example: If you have mechanics with ranks [4,2,8] and 10 cars to repair, you need to figure out how to assign cars to minimize the maximum time any single mechanic takes.
Input & Output
Constraints
- 1 โค ranks.length โค 105
- 1 โค ranks[i] โค 100
- 1 โค cars โค 106
- Time limit: 2 seconds