B - Candy Button Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 150

問題文

不思議なボタンがあります。 このボタンを押すと飴を 1 つもらえますが、前回飴をもらってからの経過時間が C 秒未満である場合はもらえません。

高橋君はこのボタンを N 回押してみることにしました。 i 回目にボタンを押すのは今から T_i 秒後です。

高橋君は何個の飴をもらうことができますか?

制約

  • 1\leq N \leq 100
  • 1\leq C\leq 1000
  • 0\leq T_1 < T_2 < \dots < T_N \leq 1000
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N C
T_1 T_2 \dots T_N

出力

高橋君がもらうことのできる飴の個数を出力せよ。


入力例 1

6 5
1 3 7 8 10 12

出力例 1

3

高橋君はボタンを 6 回押します。

  • 1 回目(今から 1 秒後):初めてボタンを押すときは必ず飴を 1 つもらえます。
  • 2 回目(今から 3 秒後):前回飴をもらってからの経過時間が 3-1=2<C 秒なので、飴はもらえません。
  • 3 回目(今から 7 秒後):前回飴をもらってからの経過時間が 7-1=6\geq C 秒なので、飴を 1 つもらえます。
  • 4 回目(今から 8 秒後):前回飴をもらってからの経過時間が 8-7=1<C 秒なので、飴はもらえません。
  • 5 回目(今から 10 秒後):前回飴をもらってからの経過時間が 10-7=3<C 秒なので、飴はもらえません。
  • 6 回目(今から 12 秒後):前回飴をもらってからの経過時間が 12-7=5\geq C 秒なので、飴を 1 つもらえます。

よって、高橋君は飴を 3 個もらうことができます。


入力例 2

3 2
0 2 4

出力例 2

3

入力例 3

10 3
0 3 4 6 9 12 15 17 19 20

出力例 3

7

Score : 150 points

Problem Statement

There is a mysterious button. When you press this button, you receive one candy, unless less than C seconds have elapsed since you last received a candy.

Takahashi decided to press this button N times. He will press the button for the i-th time T_i seconds from now.

How many candies will he receive?

Constraints

  • 1 \leq N \leq 100
  • 1 \leq C \leq 1000
  • 0 \leq T_1 < T_2 < \dots < T_N \leq 1000
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N C
T_1 T_2 \dots T_N

Output

Print the number of candies that Takahashi will receive.


Sample Input 1

6 5
1 3 7 8 10 12

Sample Output 1

3

Takahashi will press the button six times.

  • 1st press (1 second from now): You always receive a candy when pressing the button for the first time.
  • 2nd press (3 seconds from now): 3 - 1 = 2 < C seconds have elapsed since he last received a candy, so he does not receive a candy.
  • 3rd press (7 seconds from now): 7 - 1 = 6 \geq C seconds have elapsed since he last received a candy, so he receives a candy.
  • 4th press (8 seconds from now): 8 - 7 = 1 < C second has elapsed since he last received a candy, so he does not receive a candy.
  • 5th press (10 seconds from now): 10 - 7 = 3 < C seconds have elapsed since he last received a candy, so he does not receive a candy.
  • 6th press (12 seconds from now): 12 - 7 = 5 \geq C seconds have elapsed since he last received a candy, so he receives a candy.

Therefore, he receives three candies.


Sample Input 2

3 2
0 2 4

Sample Output 2

3

Sample Input 3

10 3
0 3 4 6 9 12 15 17 19 20

Sample Output 3

7