Minimize the Maximum Distance
Limits: 3 sec., 512 MiB
This problem is different from the problem "Maximize the Minimum Distance".
There are n⋅mn⋅m points on a two-dimensional plane, located in nn rows and mm columns.
The distance between the ii-th and the (i+1)(i+1)-th row is aiai.
The distance between the ii-th and the (i+1)(i+1)-th column is bibi.
You want to paint all the points in some colors. The number of colors that you can use is unlimited. However, the number of points for each color you use must be two or three.
Your goal is to minimize the maximum Euclidean distance between points of the same color. You only need to find the value of the sought distance and do not need to find the actual colors of the points.
Input
The first line contains two integers nn and mm – the number of rows and columns, respectively.
The second line contains n−1n−1 integers aiai – distances between the ii-th and the (i+1)(i+1)-th row.
The third line contains m−1m−1 integers bibi – distances between the ii-th and the (i+1)(i+1)-th column.
Output
In one line print a real number – the minimum possible maximum distance between points of the same color.
Your output will be considered correct if the absolute or relative error from the true answer is at most 10−710−7.
Constraints
2≤n,m≤3⋅1052≤n,m≤3⋅105,
1≤ai,bi≤1091≤ai,bi≤109.
Samples
Input (stdin) | Output (stdout) |
---|---|
2 3 1 4 1 | 1.0000000000 |
Input (stdin) | Output (stdout) |
---|---|
3 3 1 1 1 1 | 1.4142135624 |