fork download
  1. #include<bits/stdc++.h>
  2. #include<vector>
  3. #define ll long long
  4. #define ii int
  5. using namespace std;
  6. const ll lim = 1e6+5;
  7. ii n, m,f[lim];
  8. int main()
  9. {
  10. cin>>n>>m;
  11. vector<ii> a(n+1);
  12. for(ii i = 1; i <= n;i++){
  13. cin>>a[i];
  14. }
  15. ll t=0,d=1;
  16. for(ii i=1;i<=n;i++)
  17. {
  18. if(t==0)
  19. {
  20. if(a[i]>=a[i-1]) f[i]=d;
  21. else
  22. {
  23. t=1;
  24. f[i]=d;
  25. }
  26. }
  27. else
  28. {
  29. if(a[i]>a[i-1])
  30. {
  31. t=0;
  32. d++;
  33. f[i]=d;
  34. }
  35. else f[i]=d;
  36. }
  37. }
  38. while(m--)
  39. {
  40. ii x,y;
  41. cin>>x>>y;
  42. if(f[x]==f[y]) cout<<"Yes\n";
  43. else cout<<"No\n";
  44. }
  45. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty