Essa has presented you with one of his 3 legendary problems, you'll be given an array $A$ of $n$ non-negative integers, an integer $d$, and he asks you to find $m$, defined as:
The size of the largest subset of elements $S$ you can pick from $A$ such that the following three conditions are satisfied:
The first line will contain two integers $n$ and $d$ $(1 \le n \le 2 * 10^5, 0 \le d \le 10^9)$.
The second line will contain $n$ space-separated integers, the contents of the array $(0 \le A_i \le 10^9)$.
If there's no such subset of elements, print the integer $0$. Otherwise, print the maximum possible size of a subset $S$ that satisfies the given conditions.
Input | Output |
---|---|
4 3 1 2 3 4 Copy
|
1 Copy
|
2 3 1 2 Copy
|
0 Copy
|