n candidates. Candidate i has skill skill[i] and refuses to work for less than min_pay[i]. You must hire exactly crew_size people so that:
- everyone gets at least their minimum pay;
- pay within the crew is proportional to skill: someone with twice the skill of a colleague earns twice as much.
Return the smallest total amount the crew will cost. Answers within 10⁻⁵ of the true value are accepted.skill=[4, 2, 6], min_pay=[20, 6, 18], crew_size=2 → 24.0
Hire workers 1 and 2: both accept 3 per unit of skill, so they get 2·3 = 6 and 6·3 = 18, 24 in total. Any pair with worker 0 needs a rate of 5 and costs more.
skill=[3, 1, 2], min_pay=[9, 1, 2], crew_size=3 → 18.0
Everyone is hired. Worker 0 asks for the highest rate, 3 per unit of skill, so the bill is 3·(3 + 1 + 2) = 18.
skill=[5, 7, 3], min_pay=[10, 7, 9], crew_size=1 → 7.0
crew_size ≤ n ≤ 10⁴skill) = len(min_pay)skill[i], min_pay[i] ≤ 10⁴skill=[4, 2, 6], min_pay=[20, 6, 18], crew_size=2
24.0
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.