248

提交数: 20, 通过率: 35%, 平均分: 56.55

题目描述:

给定一个 \(1\ \times n\) 的地图,在里面玩 \(2048\),每次可以合并相邻两个(数值范围 \(1\sim 40\)),问序列中出现的最大数字的值最大是多少。注意合并后的数值并非加倍而是 \(+1\),例如 \(2\) 与 \(2\) 合并后的数值为 \(3\)。

输入格式:

The first line of input contains N, and the next N lines give the sequence of N numbers at the start  of the game.

输出格式:

Please output the largest integer Bessie can generate.

样例输入:

4
1
1
1
2

样例输出:

3

提示:

In this example shown here, Bessie first merges the second and third 1s to obtain the sequence 1 2 2 , and then she merges the 2s into a 3. Note that it is not optimal to join the first two 1s.

时间限制: 1000ms
空间限制: 128MB

来源: Usaco2016 Open Gold