#P10058. [CF261D]Maxim and Increasing Subsequence
[CF261D]Maxim and Increasing Subsequence
Maxim and Increasing Subsequence
题面翻译
给你一个长度为的数组,表示数组复制遍后首尾相连后的数组,求的最长上升子序列 有组询问 表示数组中最大的数
题目描述
Maxim loves sequences, especially those that strictly increase. He is wondering, what is the length of the longest increasing subsequence of the given sequence ?
Sequence is given as follows:
- the length of the sequence equals ;
, where operation
means taking the remainder after dividing number by number .
Sequence of length is a subsequence of sequence , if there is such increasing sequence of indexes (1<=i_{1}<i_{2}<...\ <i_{r}<=n) , that . In other words, the subsequence can be obtained from the sequence by crossing out some elements.
Sequence is increasing, if the following inequality holds: s_{1}<s_{2}<...<s_{r} .
Maxim have variants of the sequence . Help Maxim to determine for each sequence the length of the longest increasing subsequence.
输入格式
The first line contains four integers , , and $ (1<=k<=10; 1<=n,maxb<=10^{5}; 1<=t<=10^{9}; n×maxb<=2·10^{7}) $ . Each of the next lines contain integers .
Note that for each variant of the sequence the values , and coincide, the only arrays s differ.
The numbers in the lines are separated by single spaces.
输出格式
Print integers — the answers for the variants of the sequence . Print the answers in the order the variants follow in the input.
样例 #1
样例输入 #1
3 3 5 2
3 2 1
1 2 3
2 3 1
样例输出 #1
2
3
3