[POI2010] PIL-Pilots

题目描述

In the Byteotian Training Centre, the pilots prepare for missions requiring extraordinary precision and control. One measure of a pilot's capability is the duration he is able to fly along a desired route without deviating too much - simply put, whether he can fly steadily. This is not an easy task, as the simulator is so sensitive that it registers even a slightest move of the yoke1. At each moment the simulator stores a single parameter describing the yoke's position. Before each training session a certain tolerance level ![](http://main.edu.pl/images/OI17/pil-en-tex.1.png) is set. The pilots' task then is to fly as long as they can in such a way that all the yoke's position measured during the flight differ by at most ![](http://main.edu.pl/images/OI17/pil-en-tex.2.png). In other words, a fragment of the flight starting at time ![](http://main.edu.pl/images/OI17/pil-en-tex.3.png) and ending at time ![](http://main.edu.pl/images/OI17/pil-en-tex.4.png) is within tolerance level ![](http://main.edu.pl/images/OI17/pil-en-tex.5.png) if the position measurements, starting with ![](http://main.edu.pl/images/OI17/pil-en-tex.6.png)-th and ending with ![](http://main.edu.pl/images/OI17/pil-en-tex.7.png)-th, form such a sequence ![](http://main.edu.pl/images/OI17/pil-en-tex.8.png) that for all elements ![](http://main.edu.pl/images/OI17/pil-en-tex.9.png) of this sequence, the inequality ![](http://main.edu.pl/images/OI17/pil-en-tex.10.png) holds. Your task is to write a program that, given a number ![](http://main.edu.pl/images/OI17/pil-en-tex.11.png) and the sequence of yoke's position measurements, determines the length of the longest fragment of the flight that is within the tolerance level ![](http://main.edu.pl/images/OI17/pil-en-tex.12.png). 给定 $n, k$ 和一个长度为 $n$ 的序列,求最长的最大值最小值相差不超过 $k$ 的子段。

输入输出格式

输入格式


In the first line of the standard input two integers are given, ![](http://main.edu.pl/images/OI17/pil-en-tex.13.png) and ![](http://main.edu.pl/images/OI17/pil-en-tex.14.png) (![](http://main.edu.pl/images/OI17/pil-en-tex.15.png), ![](http://main.edu.pl/images/OI17/pil-en-tex.16.png)), separated by a single space, denoting the tolerance level and the number of yoke's position measurements taken. The second line gives those measurements, separated by single spaces. Each measurement is an integer from the interval from ![](http://main.edu.pl/images/OI17/pil-en-tex.17.png) to ![](http://main.edu.pl/images/OI17/pil-en-tex.18.png). 第一行两个由空格隔开的整数 $k, n$($0\leq k\leq 2\times 10 ^ 9$,$1\leq n\leq 3\times 10 ^ 6$),$k$ 表示设定的极差的最大值,$n$ 表示序列的长度。 第二行 $n$ 个由空格隔开的整数 $a_i$($1\leq a_i\leq 2\times 10^ 9$)表示序列。

输出格式


Your program should print a single integer to the standard output: the maximum length of a fragment of the flight that is within the given tolerance level. 一个整数表示符合条件的子段的长度最大值。

输入输出样例

输入样例 #1

3 9
5 1 3 5 8 6 6 9 10

输出样例 #1

4

说明

样例解释:$5, 8, 6, 6$ 和 $8, 6, 6, 9$ 都是满足条件长度为 $4$ 的子段。