1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-25 14:58:56 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你&nbsp;<code>n</code>&nbsp;个任务和&nbsp;<code>m</code>&nbsp;个工人。每个任务需要一定的力量值才能完成,需要的力量值保存在下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>tasks</code>&nbsp;中,第 <code>i</code>&nbsp;个任务需要&nbsp;<code>tasks[i]</code>&nbsp;的力量才能完成。每个工人的力量值保存在下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>workers</code>&nbsp;中,第&nbsp;<code>j</code>&nbsp;个工人的力量值为&nbsp;<code>workers[j]</code>&nbsp;。每个工人只能完成 <strong>一个</strong>&nbsp;任务,且力量值需要 <strong>大于等于</strong>&nbsp;该任务的力量要求值(即&nbsp;<code>workers[j] &gt;= tasks[i]</code>&nbsp;)。</p>\n\n<p>除此以外,你还有&nbsp;<code>pills</code>&nbsp;个神奇药丸,可以给 <strong>一个工人的力量值</strong>&nbsp;增加&nbsp;<code>strength</code>&nbsp;。你可以决定给哪些工人使用药丸,但每个工人&nbsp;<strong>最多</strong>&nbsp;只能使用&nbsp;<strong>一片</strong>&nbsp;药丸。</p>\n\n<p>给你下标从 <strong>0</strong>&nbsp;开始的整数数组<code>tasks</code> 和&nbsp;<code>workers</code>&nbsp;以及两个整数&nbsp;<code>pills</code> 和&nbsp;<code>strength</code>&nbsp;,请你返回 <strong>最多</strong>&nbsp;有多少个任务可以被完成。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><b>输入:</b>tasks = [<em><strong>3</strong></em>,<em><strong>2</strong></em>,<em><strong>1</strong></em>], workers = [<em><strong>0</strong></em>,<em><strong>3</strong></em>,<em><strong>3</strong></em>], pills = 1, strength = 1\n<b>输出:</b>3\n<strong>解释:</strong>\n我们可以按照如下方案安排药丸\n- 给 0 号工人药丸。\n- 0 号工人完成任务 20 + 1 &gt;= 1\n- 1 号工人完成任务 13 &gt;= 2\n- 2 号工人完成任务 03 &gt;= 3\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><b>输入:</b>tasks = [<em><strong>5</strong></em>,4], workers = [<em><strong>0</strong></em>,0,0], pills = 1, strength = 5\n<b>输出:</b>1\n<strong>解释:</strong>\n我们可以按照如下方案安排药丸\n- 给 0 号工人药丸。\n- 0 号工人完成任务 00 + 5 &gt;= 5\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><b>输入:</b>tasks = [<em><strong>10</strong></em>,<em><strong>15</strong></em>,30], workers = [<em><strong>0</strong></em>,<em><strong>10</strong></em>,10,10,10], pills = 3, strength = 10\n<b>输出:</b>2\n<strong>解释:</strong>\n我们可以按照如下方案安排药丸\n- 给 0 号和 1 号工人药丸。\n- 0 号工人完成任务 00 + 10 &gt;= 10\n- 1 号工人完成任务 110 + 10 &gt;= 15\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre><b>输入:</b>tasks = [<em><strong>5</strong></em>,9,<em><strong>8</strong></em>,<em><strong>5</strong></em>,9], workers = [1,<em><strong>6</strong></em>,<em><strong>4</strong></em>,2,<em><strong>6</strong></em>], pills = 1, strength = 5\n<b>输出:</b>3\n<strong>解释:</strong>\n我们可以按照如下方案安排药丸\n- 给 2 号工人药丸。\n- 1 号工人完成任务 06 &gt;= 5\n- 2 号工人完成任务 24 + 5 &gt;= 8\n- 4 号工人完成任务 36 &gt;= 5\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == tasks.length</code></li>\n\t<li><code>m == workers.length</code></li>\n\t<li><code>1 &lt;= n, m &lt;= 5 * 10<sup>4</sup></code></li>\n\t<li><code>0 &lt;= pills &lt;= m</code></li>\n\t<li><code>0 &lt;= tasks[i], workers[j], strength &lt;= 10<sup>9</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 36,
"likes": 39,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -167,7 +167,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"1.4K\", \"totalSubmission\": \"3.9K\", \"totalAcceptedRaw\": 1381, \"totalSubmissionRaw\": 3860, \"acRate\": \"35.8%\"}",
"stats": "{\"totalAccepted\": \"1.5K\", \"totalSubmission\": \"4.1K\", \"totalAcceptedRaw\": 1475, \"totalSubmissionRaw\": 4146, \"acRate\": \"35.6%\"}",
"hints": [
"Is it possible to assign the first k smallest tasks to the workers?",
"How can you efficiently try every k?"