QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 2048 MB 總分: 100

#7695. 加倍

统计

“Double Up”游戏由一个包含 $n$ 个数字的序列 $a_1, \dots, a_n$ 组成,其中每个 $a_i$ 都是 2 的幂。在一次操作中,你可以移除其中一个数字,或者将两个相同的相邻数字合并为一个两倍于原值的新数字。例如,对于序列 $4, 2, 2, 1, 8$,我们可以合并 $2$ 得到 $4, 4, 1, 8$,然后合并 $4$ 得到 $8, 1, 8$,接着移除 $1$,最后合并 $8$,得到最终的数字 $16$。我们进行该游戏直到只剩下一个数字。请问我们能得到的最大数字是多少?

输入格式

输入包含两行。第一行包含 $n$ ($1 \le n \le 1000$)。第二行包含数字 $a_1, \dots, a_n$,其中对于每个 $i$,都有 $1 \le a_i \le 2^{100}$。

输出格式

输出包含一行,表示从输入序列 $a_1, \dots, a_n$ 中可以得到的最大数字。

样例

样例输入 1

5
4 2 2 1 8

样例输出 1

16

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.