题目描述
Problem Description
You are operating a social game. This game features numerous monsters, each with two parameters: mass and magic power.
A user has $ N $ monsters, where the $ i $-th monster $(1 \leq i \leq N)$ has a mass of $ A_i $ and magic power of $ B_i $.
Additionally, there are $ M $ support monsters, where the $ i $-th support monster $(1 \leq i \leq M)$ has a mass of $ C_i $ and magic power of $ D_i $.
The user can select exactly 5 monsters from these $ N + M $ monsters to synthesize. However, only one support monster can be chosen at most. The strength of the synthesized monster is defined as the sum of the magic powers of the used monsters divided by the sum of their masses.
You want to implement a feature that automatically selects monsters to maximize the strength of the synthesized monster. Create a program that calculates the maximum strength of the synthesized monster when synthesis is performed once.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $ : $ $ A_N $ $ B_N $ $ C_1 $ $ D_1 $ $ C_2 $ $ D_2 $ $ : $ $ C_M $ $ D_M $
Output Format
Output the maximum strength of the synthesized monster as a real number. The answer will be judged correct if the absolute or relative error with the judge's output is within $ 10^{-6} $.
Sample Input and Output
Sample Input #1
6 2
10 30
20 60
10 10
30 100
50 140
40 120
10 3
30 1
Sample Output #1
3.0000000000000
Sample Input #2
6 2
1 20
1 3
32 100
1 1
1 2
2 5
10 100
96 874
Sample Output #2
9.0000000000000
Notes/Hints
Constraints
- $5 \leq N \leq 1,000$
- $1 \leq M \leq 100$
- $1 \leq A_i, B_i \leq 100,000$
- $1 \leq C_i, D_i \leq 100,000$
- All values in the input are integers.
Sample Explanation 1
It is optimal not to use any support monsters and choose the 1st, 2nd, 4th, 5th, and 6th owned monsters.
Sample Explanation 2
This time, there is a powerful support monster, and it should be used.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分