Yishui_lovely

败犬~~

HDU 3530 Subsqueue ( 单调队列

Subsqueue

题目描述

There is a sequence of integers. Your task is to find the longest subsequence that satisfies the following condition: the difference between the maximum element and the minimum element of the subsequence is no smaller than m and no larger than k.

输入

There are multiple test cases.
For each test case, the first line has three integers, n, m and k. n is the length of the sequence and is in the range [1, 100000]. m and k are in the range [0, 1000000]. The second line has n integers, which are all in the range [0, 1000000].
Proceed to the end of file.

输出

For each test case, 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

题意

求一个数列中最大最小值差值在[m,k]之间 最大的范围
思路: 维护两个单调队列(一个递增一个递减)

AC代码

阅读更多
版权声明:本文不一定是博主原创文章,欢迎各种转载 https://blog.csdn.net/wang2332/article/details/80319460
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

HDU 3530 Subsqueue ( 单调队列

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭