QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#2960. 社交距离

统计

是时候举办一场保持社交距离的聚会了!一群朋友围坐在圆桌旁,有些座位有人,有些座位空着。特别地,为了遵守社交距离协议,没有任何两个人是直接相邻坐着的。

他们想要扩大聚会规模并邀请更多的朋友,但没有人愿意离开他们当前的座位。给定当前的座位安排,确定在保持任意两人之间至少有一个空位的前提下,最多还能再坐下多少人。

输入格式

输入的第一行包含两个整数 $S$ ($3 \le S \le 1000$),表示圆桌的座位总数,以及 $N$ ($1 \le N \le S/2$),表示当前已经入座的人数。

注意,圆桌的座位按环形编号为 $1, 2, \dots, S$:对于每个 $1 \le i < S$,编号为 $i$ 和 $i+1$ 的座位直接相邻。座位 $S$ 和 $1$ 也直接相邻。

第二行包含 $N$ 个整数 $a_1, a_2, \dots, a_N$ ($1 \le a_1 < a_2 < \dots < a_N \le S$),表示当前被占用的座位编号。没有任何两个被占用的座位是直接相邻的。

输出格式

输出在保持任意两人之间至少有一个空位的前提下,最多还能再坐下多少人。

样例

样例输入 1

9 2
2 6

样例输出 1

2

样例输入 2

10 3
1 4 7

样例输出 2

1

样例输入 3

6 2
2 5

样例输出 3

0

样例输入 4

100 5
7 14 47 78 99

样例输出 4

43

样例输入 5

6 1
3

样例输出 5

2

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.