QOJ.ac

QOJ

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

#9064. 无伴奏合唱录音

统计

Geoffry 正在准备一首无伴奏合唱曲目,他将独自演唱整首歌曲。

歌曲中的每个音符都有一个 $0$ 到 $10^9$ 之间的音高。由于歌曲中音高变化较大,Geoffry 将分多次录制自己的演唱。在单次录制中,他会选择一部分音符来演唱,并准确地唱出这些音符。为了避免过度劳累嗓子,在单次录制中,他所演唱的音符的最高音高与最低音高之差不能超过一个限制值。

请计算 Geoffry 最少需要录制多少次,才能确保每个音符都至少被录制过一次。

输入格式

第一行包含两个整数 $n$ 和 $d$ ($1 \le n \le 10^5, 0 \le d \le 10^9$),其中 $n$ 是 Geoffry 歌曲中的音符数量,$d$ 是他能承受的最高音高与最低音高之间的最大差值。

接下来的 $n$ 行,每行包含一个整数 $p$ ($0 \le p \le 10^9$),表示 Geoffry 歌曲中音符的音高,按演唱顺序排列。

输出格式

输出一个整数,表示 Geoffry 最少需要录制的次数,使得每个音符都至少被录制过一次。

样例

输入 1

6 0
3
1
4
1
5
9

输出 1

5

输入 2

6 1
3
1
4
1
5
9

输出 2

4

输入 3

6 2
3
1
4
1
5
9

输出 3

3

输入 4

6 4
3
1
4
1
5
9

输出 4

2

输入 5

6 8
3
1
4
1
5
9

输出 5

1

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.