857. Minimum Cost to Hire K Workers Hard
1/**
2 * [857] Minimum Cost to Hire K Workers
3 *
4 * There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the i^th worker and wage[i] is the minimum wage expectation for the i^th worker.
5 * We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules:
6 * <ol>
7 * Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
8 * Every worker in the paid group must be paid at least their minimum wage expectation.
9 * </ol>
10 * Given the integer k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within 10^-5 of the actual answer will be accepted.
11 *
12 * Example 1:
13 *
14 * Input: quality = [10,20,5], wage = [70,50,30], k = 2
15 * Output: 105.00000
16 * Explanation: We pay 70 to 0^th worker and 35 to 2^nd worker.
17 *
18 * Example 2:
19 *
20 * Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3
21 * Output: 30.66667
22 * Explanation: We pay 4 to 0^th worker, 13.33333 to 2^nd and 3^rd workers separately.
23 *
24 *
25 * Constraints:
26 *
27 * n == quality.length == wage.length
28 * 1 <= k <= n <= 10^4
29 * 1 <= quality[i], wage[i] <= 10^4
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/minimum-cost-to-hire-k-workers/
35// discuss: https://leetcode.com/problems/minimum-cost-to-hire-k-workers/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn mincost_to_hire_workers(quality: Vec<i32>, wage: Vec<i32>, k: i32) -> f64 {
41 0f64
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_857() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.