2023-09-07力扣每日一题

链接:

[2594. 修车的最少时间](https://leetcode.cn/problems/minimum-time-to-repair-cars/)\](https://leetcode.cn/problems/form-smallest-number-from-two-digit-arrays/) **题意:** 一个能力R的人R\*N\*N分钟修N辆车,求最快多久修完(多人多车) **解:** 二分很好想,主要是怎么检查(数学废物润去看题解了) **实际代码:** ```c++ long long repairCars(vector& ranks, int cars) { typedef long long int ll; sort(ranks.begin(),ranks.end()); ll l=1,r=1ll*ranks[ranks.size()-1]*pow(cars,2); while(l>1; ll cnt=0; for(auto rank:ranks) cnt+=sqrt(m/rank); if(cnt>=cars) r=m; else l=m+1; } return l; } ``` 限制: * `1 <= ranks.length <= 105` * `1 <= ranks[i] <= 100` * `1 <= cars <= 106`

相关推荐
Fanxt_Ja3 天前
【LeetCode】算法详解#15 ---环形链表II
数据结构·算法·leetcode·链表
元亓亓亓3 天前
LeetCode热题100--105. 从前序与中序遍历序列构造二叉树--中等
算法·leetcode·职场和发展
仙俊红3 天前
LeetCode每日一题,20250914
算法·leetcode·职场和发展
_不会dp不改名_3 天前
leetcode_21 合并两个有序链表
算法·leetcode·链表
吃着火锅x唱着歌3 天前
LeetCode 3302.字典序最小的合法序列
leetcode
睡不醒的kun3 天前
leetcode算法刷题的第三十四天
数据结构·c++·算法·leetcode·职场和发展·贪心算法·动态规划
吃着火锅x唱着歌3 天前
LeetCode 978.最长湍流子数组
数据结构·算法·leetcode
爱编程的化学家3 天前
代码随想录算法训练营第十一天--二叉树2 || 226.翻转二叉树 / 101.对称二叉树 / 104.二叉树的最大深度 / 111.二叉树的最小深度
数据结构·c++·算法·leetcode·二叉树·代码随想录
吃着火锅x唱着歌3 天前
LeetCode 1446.连续字符
算法·leetcode·职场和发展
愚润求学3 天前
【贪心算法】day10
c++·算法·leetcode·贪心算法