AtCoder Regular Contest 120
E
1D Party
AtCoder
⌀ 2653
原题
← DF →
翻译中…

Problem Statement

翻译中…

There are $N$ people, Person $1$ through Person $N$, standing on a number line. Person $i$ is now at coordinate $A_i$ on the number line. Here, $A_1 < A_2 < A_3 < \dots < A_N$ and all $A_i$ are even numbers.

翻译中…

We will now hold a party for $k$ seconds. During the party, each person can freely move on the number line at a speed of at most $1$ per second. (It is also allowed to move in the negative direction within the speed limit.) The people request that the following condition be satisfied for every integer $i$ such that $1 \le i \lt N$:

翻译中…
  • there is at least one moment during the party (including the moment it ends) when Person $i$ and Person $i + 1$ are at the same coordinate.
翻译中…

Find the minimum $k$ for which there is a strategy that the people can take to satisfy all the conditions. We can prove that the answer is an integer under the Constraints of this problem.

翻译中…

Constraints

翻译中…
  • $2 \le N \le 2 \times 10^5$
  • $0 \le A_i \le 10^9$
  • $A_1 < A_2 < A_3 < \dots < A_N$
  • $A_i$ is an even number.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 A_3 \dots A_N

翻译中…

Output

翻译中…

Print the answer as an integer.

翻译中…

样例

Input #1
3
0 6 10
Output #1
5
During the party lasting $5$ seconds, each person should move as follows: - Person $1$: always moves in the positive direction at a speed of $1$. - Person $2$: moves in the positive direction at a speed of $1$ during the first $2$ seconds, then in the negative direction at a speed of $1$ during the remaining $3$ seconds. - Person $3$: always moves in the negative direction at a speed of $1$. If they move in this way, Person $2$ and Person $3$ will be at the same coordinate exactly $2$ seconds after the beginning, and Person $1$ and Person $2$ will be at the same coordinate at the end of the party. Thus, they can satisfy all the conditions for $k = 5$. For smaller $k$, there is no strategy to satisfy all of them.
Input #2
5
0 2 4 6 8
Output #2
3
During the party lasting $3$ seconds, each person should, for example, move as follows: - Person $1$: always moves in the positive direction at a speed of $1$. - Person $2$: moves in the positive direction at a speed of $1$ during the first $2$ seconds, then in the negative direction at a speed of $1$ during the remaining $1$ second. - Person $3$: does not move at all. - Person $4$: moves in the negative direction at a speed of $1$ during the first $2$ seconds, then in the positive direction at a speed of $1$ during the remaining $1$ second. - Person $5$: always moves in the negative direction at a speed of $1$.
Input #3
10
0 2 4 6 8 92 94 96 98 100
Output #3
44
题目信息
题号
arc120_e
时间限制
2 s
内存限制
1024 MB

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