Sequence and Queries 44
Time limit1sMemory limit1024 MB
For each query m k, find the longest subsequence of the first m elements whose longest increasing subsequence has length at most k.
- Level
Hard8 of 10
- Topics
- Segment tree, Dynamic programming
- Solved
- No attempts yet
Problem
Given a sequence of length , write a program that processes the following query.
m k: Print the maximum length, among the subsequences of whose longest increasing subsequence has length at most . ()
Input
The first line contains and , the length of the sequence and the number of queries. (, )
The second line contains . ()
Each of the next lines contains a query as described above.
Output
For each query, print the answer on its own line.