Class Solution
- java.lang.Object
-
- g0801_0900.s0857_minimum_cost_to_hire_k_workers.Solution
-
public class Solution extends Object
857 - Minimum Cost to Hire K Workers.Hard
There are
nworkers. You are given two integer arraysqualityandwagewherequality[i]is the quality of theithworker andwage[i]is the minimum wage expectation for theithworker.We want to hire exactly
kworkers to form a paid group. To hire a group ofkworkers, we must pay them according to the following rules:- Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
- Every worker in the paid group must be paid at least their minimum wage expectation.
Given the integer
k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within10-5of the actual answer will be accepted.Example 1:
Input: quality = [10,20,5], wage = [70,50,30], k = 2
Output: 105.00000
Explanation: We pay 70 to 0th worker and 35 to 2nd 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 0th worker, 13.33333 to 2nd and 3rd workers separately.
Constraints:
n == quality.length == wage.length1 <= k <= n <= 1041 <= quality[i], wage[i] <= 104
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublemincostToHireWorkers(int[] quality, int[] wage, int k)
-