CF533D.Landmarks

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

We have an old building with n+2n+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 did_{i} . Let's consider an ordinary column with coordinate xx . Let's assume that the coordinate of the closest to it column to the left (bearing or ordinary) is aa and the coordinate of the closest to it column to the right (also, bearing or ordinary) is bb . In this task let's assume that this column supports the segment of the ceiling from point to point (here both fractions are considered as real division). If the length of the segment of the ceiling supported by the column exceeds did_{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.

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 dd' at any (not necessarily integer) point 0<x'<x_{n+1} . If point xx' 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?

输入格式

The first line contains integer nn ( 1<=n<=1051<=n<=10^{5} ) — the number of ordinary columns.

The second line contains n+2n+2 integers x0,x1,...,xn,xn+1x_{0},x_{1},...,x_{n},x_{n+1} ( x0=0x_{0}=0 , x_{i}<x_{i+1} for 0<=i<=n0<=i<=n , xn+1<=109x_{n+1}<=10^{9} ) — the coordinates of the columns.

The third line contains nn integers d1,d2,...,dnd_{1},d_{2},...,d_{n} ( 1<=di<=1091<=d_{i}<=10^{9} ).

输出格式

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 00 . Your answer will be checked with the relative or absolute error 10410^{-4} .

输入输出样例

  • 输入#1

    2
    0 20 40 100
    15 40
    

    输出#1

    10
    
  • 输入#2

    3
    0 4 10 28 30
    9 13 5
    

    输出#2

    0
    
首页