시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB43375.000%

문제

There are $n$ books on Rikka's desk. The length, width, height and weight of the $i$-th book are $l_i$, $1$, $1$ and $w_i$ respectively. We call the two sides of length $l_i$ as long sides and two sides of length $1$ as short sides. For each book, the mass is evenly distributed in its volume.

Today, Rikka wants to stack these books on her desk. Rikka plans to do it in $n$ turns: In each turn, she will select out one book among all remaining books, and stack it directly above the previous book (The first book will be put directly on the desk). 

For tidiness, Rikka makes the following four requirements:

  • The left long sides of all books must be coplanar. So do the right long sides;
  • The plane containing all left long sides must be vertical to the ground. So do the right long sides;
  • All short sides of all books must be parallel to the border of the desk;
  • The final book stack must be stable. Falling thick books are dangerous!

Informally, the books will be stacked as the following figure:

For fun, Rikka wants to make the book stack looking as strange as possible. For each book, Rikka defines its strangeness as the horizontal distance for its front short edge to be outside the desk. The strangeness of the whole book stack is defined as the maximum strangeness of books. For example, in the previous figure, the strangeness of the book stack is equal to the length of segment TU.

Rikka wants you to come up with a stacking plan so that the strangeness of the book stack is as large as possible.

More assumptions:

  • Suppose the gravity coefficient is fixed. It will not change when the height change;
  • Suppose the shape of the desk and books would never change.

입력

The first line contains a single integer $n\ (1 \leq n \leq 20)$, the number of books.

The second line contains $n$ integers $l_i\ (1 \leq l_i \leq 10^3)$, representing the length of each book.

The third line contains $n$ integers $w_i\ (1 \leq w_i \leq 10^3)$, representing the weight of each book.

출력

Output a single line with a single real number, representing the maximum possible strangeness value.

Your answer should have an absolute error or relative error of less than $10^{-9}$.

예제 입력 1

4
2 2 2 2
1 1 1 1

예제 출력 1

2.08333333333

예제 입력 2

3
1 2 3
3 2 1

예제 출력 2

2.95833333333

힌트

For the first sample, one optimal plan is shown in the following figure.

Here the strangeness of book $1,2,3,4$ is $\frac{1}{4}, \frac{25}{12}, \frac{7}{12}, \frac{13}{12}$ respectively. Therefore, the strangeness of the book stack is $\frac{25}{12}$.