All submissions for this problem are available.
In the Kingdom of floating stones each stone has some magical value. The people in the kingdom will consider some stones as holy when the stones belongs to the holy sequence.The holy sequence must be a continuous sequence and they must be in this form stones[i]<stones[i+1]...<stones[j]>stones[j+1]>stones[j+2]..>stones[k], (i<j<k) all the stones in the interval [i..k] are holy stones.Rekoj , being evil, he will try to disrupt the holy sequence by changing the magical value of some Xth stone.People were not able to find out the holy sequence because of the frequent change in magical values of stones.Being a programmer it’s your task to help them find the length of the longest holy sequence.
First line consists of two numbers N and M
N denotes the number of stones present in the kingdom
M denotes , the number of changes the Rekoj will make.
Next line contains N integers which denote the magical value of the stones.
Next M lines will contains two integers X which denotes index and V denotes the magical value of the stone.
For each M lines, print the maximum holy sequence.
-100000 <= stones[i], V <= 100000
All the integers are distinct.
Input: 8 3 11 8 10 7 6 100 9 5 0 3 3 90 4 92 Output: 5 5 8
Example case 1. After Rekoj changed the 0th stone into 3 the maximum holy sequence will be 3 < 8
<10>7>6 so the answer is 5.
Example case 2. After Rekoj changed the 3rd stone into 90 the maximum holy sequence will be 7 <
90 < 100 > 9 > 5..
Example case 3. After Rekoj changed the 4th stone into 92 the maximum holy sequence will be the
|Time Limit:||0.5 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.