AtCoder Beginner Contest 078
D
ABS
AtCoder
⌀ 1550
原题
← C→
翻译中…

Problem Statement

翻译中…

We have a deck consisting of $N$ cards. Each card has an integer written on it. The integer on the $i$-th card from the top is $a_i$.

翻译中…

Two people X and Y will play a game using this deck. Initially, X has a card with $Z$ written on it in his hand, and Y has a card with $W$ written on it in his hand. Then, starting from X, they will alternately perform the following action:

翻译中…
  • Draw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.
翻译中…

The game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.

翻译中…

X will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?

翻译中…

Constraints

翻译中…
  • All input values are integers.
  • $1 \leq N \leq 2000$
  • $1 \leq Z, W, a_i \leq 10^9$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N Z W
a_1 a_2 ... a_N

翻译中…

Output

翻译中…

Print the score.

翻译中…

样例

Input #1
3 100 100
10 1000 100
Output #1
900
If X draws two cards first, Y will draw the last card, and the score will be $|1000 - 100| = 900$.
Input #2
3 100 1000
10 100 100
Output #2
900
If X draws all the cards first, the score will be $|1000 - 100| = 900$.
Input #3
5 1 1
1 1 1 1 1
Output #3
0
Input #4
1 1 1
1000000000
Output #4
999999999
题目信息
题号
arc085_b
时间限制
2 s
内存限制
256 MB

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