P3512 [POI 2010] 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  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 . In other words, a fragment of the flight starting at time  and ending at time  is within tolerance level  if the position measurements, starting with -th and ending with -th, form such a sequence  that for all elements  of this sequence, the inequality  holds.
Your task is to write a program that, given a number  and the sequence of yoke's position measurements, determines the length of the longest fragment of the flight that is within the tolerance level .
给定 $n, k$ 和一个长度为 $n$ 的序列,求最长的最大值最小值相差不超过 $k$ 的子段。
输入格式
无
输出格式
无
说明/提示
样例解释:$5, 8, 6, 6$ 和 $8, 6, 6, 9$ 都是满足条件长度为 $4$ 的子段。