hdu3530Subsequence【单调队列优化dp】2010多校联合
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個數字
???????? 輸出:
????????????????? 輸出滿足條件的最長子序列的長度。
解題思路:
???????? 利用單調隊列
總結
以上是生活随笔為你收集整理的hdu3530Subsequence【单调队列优化dp】2010多校联合的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: node.js模块和包
- 下一篇: java中集合的迭代操作