Find Sequence
Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 68 Accepted Submission(s): 12
Problem Description
Give you an positive integer sequence a1,a2,…,ai,…,an,
and they satisfy a1+a2+…+ai+…+an=M(0<M≤222).
We can find new sequence b1=aid1,b2=aid2,…,bx=aidx,…,by=aidy,…,bt=aidt,
where if x != y then idx!=idy.
and this sequence satisfy:
(1) b1≤b2≤…≤bt
(2) b2?b1≤b3?b2≤?≤bt?bt?1
We can find many sequences b1,b2,b3,…,bt.
But we only want to know maximum t.
Input
The first line in the input file is an Integer T(1≤T≤30).
The first line of each test case contains two integer n,M(0<M≤222).
Then a line have n integer, they represent a1,a2,…,ai,…,an.
Output
For each test case, output the maximum t.
Sample Input
2
6 19
3 2 1 3 4 6
1 4194304
4194304
Sample Output
5
1
Hint
For the first testcase, The Sequence is 1 2 3 4 6
注意这是有个单调性的,DP[i][j]满足的最优值一定DP[i][j+1]也可以取,所以在j增大的时候,k不必重新从i开始递减(因为这段重复的区间之前已经算过了)