Sereja and Increasing subsequence
All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Sereja has an array A consisting of N integers. Sereja has M queries (Li, Ri), and for each query Sereja wants to find the length of the longest increasing subsequence in the array A[Li], A[Li + 1], ..., A[Ri].
Help Sereja find the answer for each query.
The first line of the input contains an integer T denoting the number of test cases.
The description of T test cases follows.
Each test case starts with two integers N, M.
The next line contains the numbers A, A, ..., A[N]. The next M lines contains the pairs Li, Ri, which are the queries.
For each test case, output M lines - the answer for each query.
- 1 ≤ T ≤ 10
- 1 ≤ A[i], M, N
- Let S be sum of all A[i] in whole file.
- 1 ≤ S ≤ 1000000
- 1 ≤ Li ≤ Ri ≤ N
- 1 ≤ sum of all M per file ≤ 1000000
- Subtask #1: 1 ≤ N, M ≤ 100 (15 points)
- Subtask #2: 1 ≤ N, M ≤ 1000 (15 points)
- Subtask #3: original constraints (70 points)
Input: 1 5 3 2 5 1 2 3 1 5 1 3 2 4 Output: 3 2 2
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.