QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 64 MB 總分: 50

#13684. 照明

统计

现在是降临节时期。在一条长度为 $N$ 米的街道上,有 $M$ 盏路灯(街道的每一米用 $1$ 到 $N$ 的数字表示)。每盏路灯可以照亮它所在的这一米,以及该位置向左和向右各 $K$ 米的范围。换句话说,如果路灯位于第 $X$ 米,它将照亮街道上从 $X - K$ 到 $X + K$(包含两端)的所有区域。当然,街道的某一米可能会被多盏路灯照亮。所有路灯的位置都是互不相同的。

现在的问题是,现有的路灯可能无法照亮整条长度为 $N$ 米的街道。你的任务是确定最少需要额外安装多少盏路灯(安装位置在 $1$ 到 $N$ 之间),才能使整条街道都被照亮。

输入格式

输入的第一行包含一个整数 $N$ ($1 \le N \le 1000$)。

第二行包含一个整数 $M$ ($1 \le M \le N$)。

第三行包含一个整数 $K$ ($0 \le K \le N$)。

接下来的 $M$ 行,每行包含一个整数。这些数字按升序排列,表示这 $M$ 盏路灯中每一盏的位置。

这些位置互不相同,且均在区间 $[1, N]$ 内。

输出格式

输出使整条街道都被照亮所需的最少额外路灯数量。

样例

输入样例 1

5
2
2
1
5

输出样例 1

0

样例 1 说明

不需要在街道上添加路灯,因为所有 $N$ 米都已经被照亮了。

输入样例 2

26
3
3
3
19
26

输出样例 2

2

输入样例 3

13
2
10
1
2

输出样例 3

1

样例 3 说明

需要添加一盏路灯,例如在位置 13。

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.