首页 > 其他 > 详细

[LeetCode] 857. Minimum Cost to Hire K Workers 雇佣K名工人的最低成本

时间:2019-08-09 21:44:50      阅读:133      评论:0      收藏:0      [点我收藏+]



There are?N?workers.? The?i-th worker has a?quality[i]?and a minimum wage expectation?wage[i].

Now we want to hire exactly?K?workers to form a?paid group.? When hiring a group of K workers, we must pay them according to the following rules:

  1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
  2. Every worker in the paid group must be paid at least their minimum wage expectation.

Return the least amount of money needed to form a paid group satisfying the above conditions.

Example 1:

Input: quality = [10,20,5], wage = [70,50,30], K = 2
Output: 105.00000
Explanation: We pay 70 to 0-th worker and 35 to 2-th worker.

Example 2:

Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], K = 3
Output: 30.66667
Explanation: We pay 4 to 0-th worker, 13.33333 to 2-th and 3-th workers seperately.

Note:

  1. 1 <= K <= N <= 10000, where?N = quality.length = wage.length
  2. 1 <= quality[i] <= 10000
  3. 1 <= wage[i] <= 10000
  4. Answers within?10^-5?of the correct answer will be considered correct.



Github 同步地址:

https://github.com/grandyang/leetcode/issues/857



参考资料:

https://leetcode.com/problems/minimum-cost-to-hire-k-workers/



LeetCode All in One 题目讲解汇总(持续更新中...)

[LeetCode] 857. Minimum Cost to Hire K Workers 雇佣K名工人的最低成本

原文:https://www.cnblogs.com/grandyang/p/11329482.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!