mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 13:36:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>你有 <code>n</code> 台电脑。给你整数 <code>n</code> 和一个下标从 <strong>0</strong> 开始的整数数组 <code>batteries</code> ,其中第 <code>i</code> 个电池可以让一台电脑 <strong>运行 </strong><code>batteries[i]</code> 分钟。你想使用这些电池让 <strong>全部</strong> <code>n</code> 台电脑 <b>同时</b> 运行。</p>\n\n<p>一开始,你可以给每台电脑连接 <strong>至多一个电池</strong> 。然后在任意整数时刻,你都可以将一台电脑与它的电池断开连接,并连接另一个电池,你可以进行这个操作 <strong>任意次</strong> 。新连接的电池可以是一个全新的电池,也可以是别的电脑用过的电池。断开连接和连接新的电池不会花费任何时间。</p>\n\n<p>注意,你不能给电池充电。</p>\n\n<p>请你返回你可以让 <code>n</code> 台电脑同时运行的 <strong>最长</strong> 分钟数。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2022/01/06/example1-fit.png\" style=\"width: 762px; height: 150px;\"></p>\n\n<pre><b>输入:</b>n = 2, batteries = [3,3,3]\n<b>输出:</b>4\n<b>解释:</b>\n一开始,将第一台电脑与电池 0 连接,第二台电脑与电池 1 连接。\n2 分钟后,将第二台电脑与电池 1 断开连接,并连接电池 2 。注意,电池 0 还可以供电 1 分钟。\n在第 3 分钟结尾,你需要将第一台电脑与电池 0 断开连接,然后连接电池 1 。\n在第 4 分钟结尾,电池 1 也被耗尽,第一台电脑无法继续运行。\n我们最多能同时让两台电脑同时运行 4 分钟,所以我们返回 4 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2022/01/06/example2.png\" style=\"width: 629px; height: 150px;\"></p>\n\n<pre><b>输入:</b>n = 2, batteries = [1,1,1,1]\n<b>输出:</b>2\n<b>解释:</b>\n一开始,将第一台电脑与电池 0 连接,第二台电脑与电池 2 连接。\n一分钟后,电池 0 和电池 2 同时耗尽,所以你需要将它们断开连接,并将电池 1 和第一台电脑连接,电池 3 和第二台电脑连接。\n1 分钟后,电池 1 和电池 3 也耗尽了,所以两台电脑都无法继续运行。\n我们最多能让两台电脑同时运行 2 分钟,所以我们返回 2 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= n <= batteries.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= batteries[i] <= 10<sup>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 45,
|
||||
"likes": 47,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"3.6K\", \"totalSubmission\": \"9.2K\", \"totalAcceptedRaw\": 3586, \"totalSubmissionRaw\": 9208, \"acRate\": \"38.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"3.9K\", \"totalSubmission\": \"10K\", \"totalAcceptedRaw\": 3944, \"totalSubmissionRaw\": 10027, \"acRate\": \"39.3%\"}",
|
||||
"hints": [
|
||||
"For a given running time, can you determine if it is possible to run all n computers simultaneously?",
|
||||
"Try to use Binary Search to find the maximal running time"
|
||||
|
Reference in New Issue
Block a user