Description
There is asequence(顺序,序列) of integers.Your task is to find the longest subsequence(子序列) that satisfies the following condition: the differencebetween the maximum element and the minimum element of the subsequence is nosmaller than m and no larger than k.
Input
There aremultiple test cases.
For each test case, the first line has three integers, n, m and k. n is thelength of the sequence and is in the range [1, 100000]. m and k are in therange [0, 1000000]. The second line has n integers, which are all in the range[0, 1000000].
Proceed to the end of file.
Output
For each testcase, print the length of the subsequence on a single line.
Sample Input
5 0 0
1 1 1 1 1
5 0 3
1 2 3 4 5
Sample Output
5
4
题意:给你一串序列,你的任务是根据紧随的条件找出这个最长子序列:子序列最大与最小值之差不超过k且不小于m
输入:
多组测试数据,对于每组测试数据,第一行是n,m,k三个数,n是序列的长度,第二行有n个数字
输出:
输出满足条件的最长子序列的长度。
解题思路:
利用单调队列