Question
Range Quest
Lila is given an array B of size M and a value P. She needs to find the largest subarray where the difference between the maximum and minimum elements is at most P.
Input
The first line of the input contains two integers M and P.
The second line of the input contains M space-separated integers, representing an array B.
Constraints
1 ≤ M ≤ 105
1 ≤ P ≤ 109
1 ≤ Bi ≤ 109
The second line of the input contains M space-separated integers, representing an array B.
Constraints
1 ≤ M ≤ 105
1 ≤ P ≤ 109
1 ≤ Bi ≤ 109
Output
Print the maximum subarray size such that the difference between the maximum and minimum elements of the subarray is ≤ P.
Example
Sample Input
5 3
3 5 2 7 1
Sample Input
3
Explanation
We can take subarray [3, 5, 2]. No subarray of size 4 or larger will satisfy the condition.
5 3
3 5 2 7 1
Sample Input
3
Explanation
We can take subarray [3, 5, 2]. No subarray of size 4 or larger will satisfy the condition.