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:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.4, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions