Equality

All submissions for this problem are available.
### Read problem statements in [Hindi](http://www.codechef.com/download/translated/JAN20/hindi/ISBIAS.pdf), [Bengali](http://www.codechef.com/download/translated/JAN20/bengali/ISBIAS.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/JAN20/mandarin/ISBIAS.pdf), [Russian](http://www.codechef.com/download/translated/JAN20/russian/ISBIAS.pdf), and [Vietnamese](http://www.codechef.com/download/translated/JAN20/vietnamese/ISBIAS.pdf) as well. Chef Aditi keeps changing the flavours of her dishes and she wants to analyse feedback from her customers in order to improve her performance. The customers visiting Aditi's restaurant can rate the food online and Aditi knows an aggregated rating for each day. As she is busy cooking, you should perform the data analysis. You are given a sequence $A_1, A_2, \ldots, A_N$ of distinct integers denoting the customers' feedback during $N$ days. You should process $Q$ queries. In each query, you are given two integers $L$ and $R$. Consider any contiguous subsequence $A_p, A_{p+1}, \ldots, A_q$, where $L \le p < q \le R$; let's call it a *maximal increasing subsequence* if the following conditions hold:  $A_p \lt A_{p+1} \ldots \lt A_q$  if $p \gt L$, then $A_p \lt A_{p1}$  if $q \lt R$, then $A_q \gt A_{q+1}$ Similarly, let's define a *maximal decreasing subsequence*. You should find out if the number of maximal increasing subsequences is equal to the number of maximal decreasing subsequences (with $L \le p < q \le R$). For example, if $A = (10, 20, 30, 5)$, we can see that the only maximal increasing subsequence of this sequence (for $L=1$ and $R=N$) is $(10, 20, 30)$, since $(10, 20)$ does not satisfy the third condition and $(20, 30)$ does not satisfy the second condition, and there is only one maximal decreasing subsequence $(30, 5)$. ### Input  The first line of the input contains two spaceseparated integers $N$ and $Q$.  The second line contains $N$ spaceseparated integers $A_1, A_2, \ldots, A_N$.  $Q$ lines follow. Each of these lines contains two spaceseparated integers $L$ and $R$ describing a query. ### Output For each query, print a single line containing the string `"YES"` if the number of maximal increasing contiguous subsequences is equal to the number of maximal decreasing contiguous subsequences or `"NO"` otherwise (without quotes). ### Constraints  $2 \le N \le 10^5$  $1 \le Q \le 10^5$  $1 \le A_i \le 10^9$ for each valid $i$  $1 \le L \lt R \le N$  $A_1, A_2, \ldots, A_N$ are pairwise distinct ### Subtasks **Subtasks #1 (20 points):** $Q \le 50$ **Subtasks #2 (80 points):** original constraints ### Example Input 1 ``` 4 3 1 3 2 4 1 4 2 3 2 4 ``` ### Example Output 1 ``` NO NO YES ``` ### Explanation 1 For the first query, there are two maximal increasing subsequences $(1, 3)$ and $(2, 4)$, but only one maximal decreasing subsequence $(3, 2)$.Author:  sahi1422 
Editorial  https://discuss.codechef.com/problems/ISBIAS 
Tags  easy, jan20, observations, sahi1422, sahi1422, vijju123 
Date Added:  19112019 
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, rust, SCALA, swift, 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, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 