#P7801. [COCI 2015/2016 #6] KRUMPIRKO

[COCI 2015/2016 #6] KRUMPIRKO

Problem Description

Mr. Potato\text{Mr. Potato} opened two new shops to sell potatoes. He bought NN bags of potatoes. The ii-th bag costs cic_i and contains aia_i potatoes. He plans to distribute all NN bags between the two shops, bag by bag.

In each shop, the average price of potatoes equals the total cost of all bags in that shop divided by the total number of potatoes in that shop. (Note that it is the number of potatoes, not the number of bags.)

Let P1P_1 be the average potato price in the first shop, and P2P_2 be the average potato price in the second shop. Mr. Potato\text{Mr. Potato} wants to minimize P1×P2P_1 \times P_2, under the condition that in at least one shop, the number of bags is exactly LL.

Input Format

The first line contains two integers NN and LL.

The second line contains NN integers aia_i.

The third line contains NN integers cic_i.

Output Format

Output one floating-point number on the first line: the minimum value of P1×P2P_1 \times P_2, rounded to three digits after the decimal point.

3 1
3 2 1
1 2 3
0.556
3 2
2 2 2
3 3 3
2.250

Hint

Constraints

For 30%30\% of the testdata, 2N202 \le N \le 20.

For 100%100\% of the testdata, 2N1002 \le N \le 100, 1L<N1 \le L < N, 1ai1001 \le a_i \le 100, 1ci1061 \le c_i \le 10^6, i=1Nai500\sum\limits_{i=1}^{N} a_i \le 500.

Source

Translated from COCI 2015-2016 CONTEST #6 T5 KRUMPIRKO.

The score of this problem follows the original COCI setting, with a full score of 140140.

Translated by ChatGPT 5