#P7801. [COCI 2015/2016 #6] KRUMPIRKO
[COCI 2015/2016 #6] KRUMPIRKO
Problem Description
opened two new shops to sell potatoes. He bought bags of potatoes. The -th bag costs and contains potatoes. He plans to distribute all 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 be the average potato price in the first shop, and be the average potato price in the second shop. wants to minimize , under the condition that in at least one shop, the number of bags is exactly .
Input Format
The first line contains two integers and .
The second line contains integers .
The third line contains integers .
Output Format
Output one floating-point number on the first line: the minimum value of , 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 of the testdata, .
For of the testdata, , , , , .
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 .
Translated by ChatGPT 5