QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#3605. 不用了,谢谢!

统计

在纸牌游戏“No Thanks!”中,牌堆由编号为 1 到 36 的 36 张牌组成,玩家在游戏过程中将牌收集到自己的得分堆中。玩家的最终得分是其所收集牌上数字的总和,但有一个例外:如果玩家收集了任何两张或多张数字连续的牌,则该组牌中只有最小的那个数字计入得分。你的任务是计算单个玩家牌堆的得分,尽管在这里我们允许使用比 36 张牌大得多的牌堆进行游戏。

输入格式

第一行包含一个整数 $n$,表示收集到的牌的数量。第二行包含 $n$ 个整数,表示收集到的牌上的数字。你可以假设 $1 \le n \le 90\,000$,所有牌的数值都在 $1 \dots 90\,000$ 的范围内,且没有重复的牌值。

输出格式

输出一行,包含给定牌组的得分。

样例

样例输入 1

5
1 7 5 3 4

样例输出 1

11

样例输入 2

6
2 1 3 8 4 5

样例输出 2

9

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.