問題一覧 > 通常問題

No.2757 Pin Game

レベル : / AI推定難易度 : 243 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 153
作問者 : 👑 magurofly / テスター : 👑 binap matcharate12 aplysiaSheep
お気に入りにしたユーザー ProblemId : 5699 / 自分の提出
問題文最終更新日: 2024-04-30 12:14:19
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 430 (順位表) の他の問題:

Problem Statement

There are $N$ pins standing on a number line. The coordinate of the $i$-th pin from the left is $X_i$.

You came up with the following game.

You choose some of the pins and remove them so that the distances between the remaining pins are all at least $K$.

Find the maximum number of pins that can remain.

Input

$N\ K$
$X_1\ X_2\ \cdots\ X_N$
  • $1 \le N \le 3\times 10^5$
  • $1 \le K \le 10^9$
  • $-10^9 \le X_1 \lt X_2 \lt \cdots \lt X_N \le 10^9$
  • All inputs are integers.

Output

Print the answer on $1$ line, followed by a newline.

Sample

Sample 1
Input
5 3
1 2 5 6 8
Output
3

By keeping the $2, 3, 5$-th pins, you can achieve $3$ pins. It is not possible to keep $4$ or more pins.

Sample 2
Input
5 2
1 2 3 4 5
Output
3

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。