From d462aec15e340de4cb3d6a1c8c55328dbfb8c35c Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Sun, 16 Mar 2025 22:25:34 +0530 Subject: [PATCH] Create 2594. Minimum Time to Repair Cars --- 2594. Minimum Time to Repair Cars | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2594. Minimum Time to Repair Cars 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