Minimum Cost to Hire K Workers
You want to hire exactly k workers from n candidates, each with a quality[i] and a minimum wage expectation wage[i]. Every hired worker must be paid in proportion to their quality relative to the others in the group, and at least their own minimum wage. Return the minimum total cost to form such a group. Answers within 1e-5 of the true value are accepted.
Open official problem prompt ↗Choose exactly k workers and a single pay-rate that satisfies everyone's minimum wage, minimizing the total payout.
Setting one hourly rate for a whole crew: the rate is dictated by the most 'expensive' member (highest pay demand per unit of work). To keep the bill down, once that rate is fixed you want teammates who contribute the least billable hours.
- Input
- quality = [10, 20, 5], wage = [70, 50, 30], k = 2
- Output
- 105.0
- Why
- Hiring workers 0 and 2 at rate 7 per quality unit (worker 0 needs 70/10 = 7) costs 7*(10+5) = 105, the cheapest valid pair.
n == quality.length == wage.length1 <= k <= n <= 10^41 <= quality[i], wage[i] <= 10^4