CF-811B
阅读原文时间:2023年07月15日阅读:1

B. Vladik and Complicated Book

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [_p_1, p_2, …, _p__n], where p__i denotes the number of page that should be read i-th in turn.

Sometimes Vladik’s mom sorted some subsegment of permutation P from position l to position r inclusive, because she loves the order. For every of such sorting Vladik knows number x — what index of page in permutation he should read. He is wondered if the page, which he will read after sorting, has changed. In other words, has p__x changed? After every sorting Vladik return permutation to initial state, so you can assume that each sorting is independent from each other.

Input

First line contains two space-separated integers nm (1 ≤ n, m ≤ 104) — length of permutation and number of times Vladik's mom sorted some subsegment of the book.

Second line contains n space-separated integers p_1, _p_2, …, _p__n (1 ≤ p__i ≤ n) — permutation P. Note that elements in permutation are distinct.

Each of the next m lines contains three space-separated integers l__ir__ix__i (1 ≤ l__i ≤ x__i ≤ r__i ≤ n) — left and right borders of sorted subsegment in i-th sorting and position that is interesting to Vladik.

Output

For each mom’s sorting on it’s own line print "Yes", if page which is interesting to Vladik hasn't changed, or "No" otherwise.

Examples

input

5 5
5 4 3 2 1
1 5 3
1 3 1
2 4 3
4 4 4
2 5 3

output

Yes
No
Yes
Yes
No

input

6 5
1 4 3 2 5 6
2 4 3
1 6 2
4 5 4
1 3 3
2 6 3

output

Yes
No
Yes
No
Yes

Note

Explanation of first test case:

题意:

给出一个长为n的序列,有m次询问,每次将序列的l~r个数做sort(),问第x个数是否变。

求出原序列l~r之间x前有多少数小于x,记为ans。若x-l==ans,则x的位置不会发生变化。

AC代码:

#include
using namespace std;

const int MAXN=;

int a[MAXN];

int main(){
ios::sync_with_stdio(false);
int n,m,l,r,x;
cin>>n>>m;
for(int i=;i<=n;i++){ cin>>a[i];
}
for(int i=;i>l>>r>>x;
int ans=;
for(int i=l;i<=r;i++){
if(a[i]<a[x])
ans++;
}
if(x-l==ans)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return ;
}