Concise Binary Search | C++
\nclass Solution {\n    bool good2(long long x, long long i, long long t) {\n        return i * x * x < t;\n    }\n    bool good1(long long x, vector<int>& rank
```\nclass Solution {\n    bool good2(long long x, long long i, long long t) {\n        return i * x * x < t;\n    }\n    bool good1(long long x, vector<int>& ranks, int cars) {\n        long long cnt = 0;\n        for(int i : ranks) {\n            long long s = 0, e = cars, a = 0;\n            while(s <= e) {\n                long long m = (s + e) / 2;\n                if(good2(m, i, x)) s = m + 1, a = m;\n                else e = m - 1;\n            }\n            cnt += a;\n        }\n        return cnt >= cars;\n    }\npublic:\n    long long repairCars(vector<int>& ranks, int cars) {\n        long long s = 0, e = 1e18, ans;\n        while(s <= e) {\n            long long m = (s + e) / 2;\n            if(good1(m, ranks, cars)) e = m - 1, ans = m;\n            else s = m + 1;\n        }\n        return ans - 1;\n    }\n};\n```
['Binary Search', 'C++']