A9784 | Landmarks
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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  to point  (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.
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?
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  to point  (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.
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?
输入格式
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}$ ).
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}$ ).
输出格式
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}$ .
输入输出样例
输入 #1
2 0 20 40 100 15 40
输出 #1
10
输入 #2
3 0 4 10 28 30 9 13 5
输出 #2
0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted