VK Cup 2015 - Round 2 (unofficial online mirror, Div. 1 only)
D
Landmarks
Codeforces
3000
原题
← CE →
翻译中…

We have an old building with $*n* + 2$ columns in a row. These columns support the ceiling. These columns are located in points with coordinates $0 = *x*_{0} < *x*_{1} < ... < *x*_{*n*} < *x*_{*n* + 1}$. The leftmost and the rightmost columns are special, we will call them bearing, the other columns are ordinary.

翻译中…

For each column we know its durability $*d*_{*i*}$. Let's consider an ordinary column with coordinate $*x*$. Let's assume that the coordinate of the closest to it column to the left (bearing or ordinary) is $*a*$ and the coordinate of the closest to it column to the right (also, bearing or ordinary) is $*b*$. In this task let's assume that this column supports the segment of the ceiling from point image to point image (here both fractions are considered as real division). If the length of the segment of the ceiling supported by the column exceeds $*d*_{*i*}$, then the column cannot support it and it crashes after a while, and after that the load is being redistributeed between the neighbouring columns according to the same principle.

翻译中…

image

翻译中…

Thus, ordinary columns will be crashing for some time until the process stops at some state. One can prove that the set of the remaining columns doesn't depend on the order in which columns crash. If there are only two bearing columns left in the end, then we assume that the whole construction crashes under the weight of the roof. But if at least one ordinary column stays in addition to the bearing ones, then the building doesn't crash.

翻译中…

To make the building stronger, we can add one extra ordinary column of arbitrary durability $*d*'$ at any (not necessarily integer) point $0 < *x*' < *x*_{*n* + 1}$. If point $*x*'$ is already occupied by an ordinary column, it is replaced by a new one.

翻译中…

Your task is to find out: what minimal durability can the added column have so that the building doesn't crash?

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — the number of ordinary columns.

翻译中…

The second line contains $*n* + 2$ integers $*x*_{0}, *x*_{1}, ..., *x*_{*n*}, *x*_{*n* + 1}$ ($*x*_{0} = 0$, $*x*_{*i*} < *x*_{*i* + 1}$ for $0 ≤ *i* ≤ *n*$, $*x*_{*n* + 1} ≤ 10^{9}$) — the coordinates of the columns.

翻译中…

The third line contains $*n*$ integers $*d*_{1}, *d*_{2}, ..., *d*_{*n*}$ ($1 ≤ *d*_{*i*} ≤ 10^{9}$).

翻译中…

Output

翻译中…

Print a single number — the minimum possible durability of the column that you need to add in order to make the building stay. If you do not have to add the column, please print $0$. Your answer will be checked with the relative or absolute error $10^{ - 4}$.

翻译中…

样例

Input #1
2
0 20 40 100
15 40
Output #1
10
InputCopy OutputCopy
Input #2
3
0 4 10 28 30
9 13 5
Output #2
0
InputCopy OutputCopy
题目信息
题号
533D
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。