1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/雇佣 K 名工人的最低成本 [minimum-cost-to-hire-k-workers].html
2022-03-29 12:43:11 +08:00

40 lines
1.7 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;名工人。&nbsp;给定两个数组&nbsp;<code>quality</code>&nbsp;&nbsp;<code>wage</code>&nbsp;,其中,<code>quality[i]</code>&nbsp;表示第&nbsp;<code>i</code>&nbsp;名工人的工作质量,其最低期望工资为&nbsp;<code>wage[i]</code>&nbsp;</p>
<p>现在我们想雇佣&nbsp;<code>k</code>&nbsp;名工人组成一个<em>工资组。</em>在雇佣&nbsp;一组 <code>k</code>&nbsp;名工人时,我们必须按照下述规则向他们支付工资:</p>
<ol>
<li>对工资组中的每名工人,应当按其工作质量与同组其他工人的工作质量的比例来支付工资。</li>
<li>工资组中的每名工人至少应当得到他们的最低期望工资。</li>
</ol>
<p>给定整数 <code>k</code> ,返回 <em>组成满足上述条件的付费群体所需的最小金额&nbsp;</em>。在实际答案的&nbsp;<code>10<sup>-5</sup></code>&nbsp;以内的答案将被接受。。</p>
<p>&nbsp;</p>
<ol>
</ol>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入: </strong>quality = [10,20,5], wage = [70,50,30], k = 2
<strong>输出: </strong>105.00000
<strong>解释:</strong> 我们向 0 号工人支付 70向 2 号工人支付 35。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入: </strong>quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3
<strong>输出: </strong>30.66667
<strong>解释: </strong>我们向 0 号工人支付 4向 2 号和 3 号分别支付 13.33333。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == quality.length == wage.length</code></li>
<li><code>1 &lt;= k &lt;= n &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= quality[i], wage[i] &lt;= 10<sup>4</sup></code></li>
</ul>