LearnPy Hub
← Arena
AdvancedRating 1900

Cheapest Group of k Workers

Each worker has a quality qᵢ and a minimum wage wᵢ. Hire exactly k workers and pay each one in proportion to their quality, with every worker getting at least their minimum. Print the least total pay, rounded to 5 decimal places.

Input

n and k; the n qualities; the n minimum wages.

Output

One number.

Sample 1

Input
3 2
10 20 5
70 50 30
Output
105.00000

Sample 2

Input
5 3
3 1 10 10 1
4 8 2 2 7
Output
30.66667
solution.py
Output appears here
Cheapest Group of k Workers · Python Arena problem · LearnPy Hub