Best Easy Solution - Minimum Time to Repair Cars
Using Binary Search
# Using Binary Search
```cpp []
class Solution {
public:
    typedef long long ll;

    bool solve(vector<int>& ranks, int& cars, ll& mid) {
        ll carsFixed = 0;

        for (auto& r : ranks)
            carsFixed += sqrt(mid / r);

        return carsFixed >= cars;
    }

    ll repairCars(vector<int>& ranks, int cars) {
        ll l = 1;
        ll r = (1LL * *max_element(begin(ranks), end(ranks))) * cars * cars;
        ll result = -1;

        while (l <= r) {
            ll mid = l + (r - l) / 2;
            if (solve(ranks, cars, mid)) {
                result = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }

        return result;
    }
};
```
['C++']