AtCoder Regular Contest 184
C
Mountain and Valley Folds
AtCoder
⌀ 3108
原题
← BD →
翻译中…

Problem Statement

翻译中…

We have a long, thin piece of paper whose thickness can be ignored. We perform the following operation $100$ times: lift the right end, fold it so that it aligns with the left end using the center as a crease. After completing the $100$ folds, we unfold the paper back to its original state. At this point, there are $2^{100} - 1$ creases on the paper, and these creases can be classified into two types: mountain folds and valley folds. The figure below represents the state after performing the operation twice, where red solid lines represent mountain folds and red dashed lines represent valley folds.

翻译中…

About mountain and valley folds A crease is a mountain fold if it is folded so that the back sides of the paper come together at the crease. A crease is a valley fold if it is folded so that the front sides of the paper come together at the crease.

翻译中…

image of folds

翻译中…

You are given a sequence $A = (A_1, A_2, \dots, A_N)$ of $N$ non-negative integers. Here, $0 = A_1 < A_2 < \dots < A_N \leq 10^{18}$.

翻译中…

For each integer $i$ from $1$ through $2^{100} - A_N - 1$, define $f(i)$ as follows:

翻译中…
  • The number of $k = 1, 2, \dots, N$ such that the $(i + A_k)$-th crease from the left is a mountain fold.
翻译中…

Find the maximum value among $f(1), f(2), \dots, f(2^{100} - A_N - 1)$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 10^3$
  • $0 = A_1 < A_2 < \dots < A_N \leq 10^{18}$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \cdots A_N

翻译中…

Output

翻译中…

Print the answer in one line.

翻译中…

样例

Input #1
4
0 1 2 3
Output #1
3
If mountain and valley folds are represented by `M` and `V`, respectively, there is a contiguous subsequence of creases like `MMVM`. There is no contiguous subsequence like `MMMM`, so the answer is $3$.
Input #2
6
0 2 3 5 7 8
Output #2
4
题目信息
题号
arc184_c
时间限制
2 s
内存限制
1024 MB

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