Codeforces Round 441 (Div. 1, by Moscow Team Olympiad)
E
Delivery Club
Codeforces
2600
原题
← DF →
翻译中…

Petya and Vasya got employed as couriers. During the working day they are to deliver packages to $*n*$ different points on the line. According to the company's internal rules, the delivery of packages must be carried out strictly in a certain order. Initially, Petya is at the point with the coordinate $*s*_{1}$, Vasya is at the point with the coordinate $*s*_{2}$, and the clients are at the points $*x*_{1}, *x*_{2}, ..., *x*_{*n*}$ in the order of the required visit.

翻译中…

The guys agree in advance who of them will deliver the package to which of the customers, and then they act as follows. When the package for the $*i*$-th client is delivered, the one who delivers the package to the $(*i* + 1)$-st client is sent to the path (it can be the same person who went to the point $*x*_{*i*}$, or the other). The friend who is not busy in delivering the current package, is standing still.

翻译中…

To communicate with each other, the guys have got walkie-talkies. The walkie-talkies work rather poorly at great distances, so Petya and Vasya want to distribute the orders so that the maximum distance between them during the day is as low as possible. Help Petya and Vasya to minimize the maximum distance between them, observing all delivery rules.

翻译中…

Input

翻译中…

The first line contains three integers $*n*$, $*s*_{1}$, $*s*_{2}$ ($1 ≤ *n* ≤ 100 000$, $0 ≤ *s*_{1}, *s*_{2} ≤ 10^{9}$) — number of points of delivery and starting positions of Petya and Vasya.

翻译中…

The second line contains $*n*$ integers $*x*_{1}, *x*_{2}, ..., *x*_{*n*}$ — customers coordinates ($0 ≤ *x*_{*i*} ≤ 10^{9}$), in the order to make a delivery.

翻译中…

It is guaranteed, that among the numbers $*s*_{1}, *s*_{2}, *x*_{1}, ..., *x*_{*n*}$ there are no two equal.

翻译中…

Output

翻译中…

Output the only integer, minimum possible maximal distance between couriers during delivery.

翻译中…

Note

翻译中…

In the first test case the initial distance between the couriers is $10$. This value will be the answer, for example, Petya can perform both deliveries, and Vasya will remain at the starting point.

翻译中…

In the second test case you can optimally act, for example, like this: Vasya delivers the package to the first customer, Petya to the second and, finally, Vasya delivers the package to the third client. With this order of delivery, the distance between the couriers will never exceed $1$.

翻译中…

In the third test case only two variants are possible: if the delivery of a single package is carried out by Petya, the maximum distance between them will be $5 - 2 = 3$. If Vasya will deliver the package, the maximum distance is $4 - 2 = 2$. The latter method is optimal.

翻译中…

样例

Input #1
2 0 10
5 6
Output #1
10
InputCopy OutputCopy
Input #2
3 2 1
3 4 5
Output #2
1
InputCopy OutputCopy
Input #3
1 4 5
2
Output #3
2
InputCopy OutputCopy
题目信息
题号
875E
时间限制
2 s
内存限制
512 MB
标签
二分
数据结构
动态规划

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