diff --git a/2594. Minimum Time to Repair Cars b/2594. Minimum Time to Repair Cars new file mode 100644 index 0000000..d1e8ef3 --- /dev/null +++ b/2594. Minimum Time to Repair Cars @@ -0,0 +1,27 @@ +class Solution { +public: + int freq[101]={0}, minR=101, maxR=0; + inline bool canRepair(int cars, long long t){ + long long cnt=0; + for(int x=minR; x<=maxR; x++) { + cnt+=freq[x]*(long long)sqrt(t/x); + if (cnt>=cars) return 1; + } + return cnt>=cars; + } + long long repairCars(vector& ranks, int cars) { + for(int x: ranks){ + minR=min(x, minR); + maxR=max(x, maxR); + freq[x]++; + } + long long l=1, r=1LL*minR*cars*cars, m; + + while(l