1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-14 20:01:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/安排工作以达到最大收益 [most-profit-assigning-work].html
2022-03-29 12:43:11 +08:00

42 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>你有 <code>n</code>&nbsp;个工作和 <code>m</code> 个工人。给定三个数组:&nbsp;<code>difficulty</code>,&nbsp;<code>profit</code>&nbsp;&nbsp;<code>worker</code>&nbsp;,其中:</p>
<ul>
<li><code>difficulty[i]</code>&nbsp;表示第 <code>i</code> 个工作的难度,<code>profit[i]</code> 表示第 <code>i</code> 个工作的收益。</li>
<li><code>worker[i]</code> 是第 <code>i</code> 个工人的能力,即该工人只能完成难度小于等于 <code>worker[i]</code> 的工作。</li>
</ul>
<p>每个工人&nbsp;<strong>最多</strong> 只能安排 <strong>一个</strong> 工作,但是一个工作可以 <strong>完成多次</strong></p>
<ul>
<li>举个例子,如果 3 个工人都尝试完成一份报酬为 <code>$1</code> 的同样工作,那么总收益为 <code>$3</code>&nbsp;。如果一个工人不能完成任何工作,他的收益为 <code>$0</code></li>
</ul>
<p>返回 <em>在把工人分配到工作岗位后,我们所能获得的最大利润&nbsp;</em></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入: </strong>difficulty = [2,4,6,8,10], profit = [10,20,30,40,50], worker = [4,5,6,7]
<strong>输出: </strong>100
<strong>解释: </strong>工人被分配的工作难度是 [4,4,6,6] ,分别获得 [20,20,30,30] 的收益。</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> difficulty = [85,47,57], profit = [24,66,99], worker = [40,25,25]
<strong>输出:</strong> 0</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == difficulty.length</code></li>
<li><code>n == profit.length</code></li>
<li><code>m == worker.length</code></li>
<li><code>1 &lt;= n, m &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= difficulty[i], profit[i], worker[i] &lt;= 10<sup>5</sup></code></li>
</ul>