CPP || 100% beats || very easy to understand
Complexity
Time complexity: O(N * log(max))

Space complexity: O(1)
Code
# Complexity
- Time complexity: O(N * log(max))
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
![upvote.jpg](https://assets.leetcode.com/users/images/03298a8f-2d5a-47ad-82f0-306c1fcc80eb_1742127217.1776853.jpeg)

# Code
```cpp []
class Solution {
public:
    bool is(long long mid,vector<int>&v,int cars){
        long long carr=0;
        for(long i:v){
            carr += sqrt((1.0*mid)/i);
            if(cars <= carr) return true;
        }
        return false;
    }
    long long repairCars(vector<int>& ranks, int cars) {
        long long start = *min_element(ranks.begin(),ranks.end());
        long long end = *max_element(ranks.begin(),ranks.end());
        end = (long long)end * cars * cars;
        long long ans = end;
        while(start<=end){
            long long mid = start + (end - start)/2;
            if(is(mid,ranks,cars)){
                end = mid - 1;
                ans = mid;
            }else{
                start = mid+1;
            }
        }
        return ans;
    }
};
```
['Array', 'Binary Search', 'C++']