#P1570. KC 喝咖啡

KC 喝咖啡

Description

KC and SH often went to 85°C in Fuzhou to drink coffee or something else.

One day, KC wanted a cup of coffee. The waiter told him there are nn kinds of seasonings, and exactly mm of them can be added to this cup of coffee (KC will add exactly mm kinds, not fewer). Depending on which seasonings are added, the time needed to make the coffee and the resulting deliciousness will differ.

After learning all nn seasonings, as a former chemistry contest ace, KC immediately knows the time cost cic _ i and the deliciousness viv _ i of each seasoning. Since KC is in a hurry to get back to solving problems, he wants to drink the coffee as soon as possible, but he also wants it to be delicious. So he came up with a plan: he wants to drink the coffee that maximizes vici\dfrac{\sum v _ i}{\sum c _ i}, that is, the deliciousness per unit time.

Now KC tells SH the information about the seasonings and asks SH to compute the vici\dfrac{\sum v _ i}{\sum c _ i} of the coffee he will drink. But SH does not want to help, so KC turns to you.

Note: \sum denotes summation, so vici\dfrac{\sum v _ i}{\sum c _ i} means the total deliciousness divided by the total time cost.

Input Format

The input consists of three lines.

  • The first line contains two integers n,mn, m, the number of seasonings and the number to add.
  • The next two lines each contain nn integers. In these two lines, the ii-th integer of the first line is the deliciousness viv _ i of seasoning ii, and the ii-th integer of the second line is the time cost cic _ i of seasoning ii.

Output Format

Output a real number TT, the maximum value of vici\dfrac{\sum v _ i}{\sum c _ i} for KC’s coffee, rounded to three decimal places.

3 2
1 2 3
3 2 1

1.667

Hint

Explanation for Sample 1:

KC chooses seasonings 22 and 33, $\dfrac{\sum v _ i}{\sum c _ i} = \dfrac{2 + 3}{2 + 1} = 1.667$.

It can be verified that there is no better choice.

Constraints:

For 20%20 \% of the testdata: 1n51 \leq n \leq 5.

For 50%50 \% of the testdata: 1n101 \leq n \leq 10.

For 80%80 \% of the testdata: 1n501 \leq n \leq 50.

For 100%100 \% of the testdata: $1 \leq n \leq 200, 1 \leq m \leq n, 1 \leq c[i], v[i] \leq 1 \times 10 ^ 4$.

The testdata guarantees that the answer does not exceed 10001000.

Translated by ChatGPT 5