#include #include #include int Input(){ int a = 0; std::cin>>a; return a; } int main(){ int n = 0, q = 0; n = Input(); q = Input(); std::vector arr; for(int i = 0; i < n; i++){ int a = Input(); arr.push_back(a); } std::vector nonDec; nonDec.push_back(0); int prevNum = arr[0]; for(int i = 1; i < n; i++){ if(arr[i] < prevNum) nonDec.push_back(i); else nonDec.push_back(nonDec.back()); prevNum = arr[i]; } for(int i = 0; i < q ; i++){ int from = Input() - 1; int to = Input() - 1; if(from == to){ std::cout << "YES" << std::endl; continue; } if(nonDec[from] != nonDec[to]){ std::cout << "NO" << std::endl; continue; } std::cout << "YES" << std::endl; // int prev = arr[from++]; // bool flag = true; // while(from <= to){ // if(arr[from++] < prev){ // flag = false; // break; // } // } // if(flag){ // std::cout << "YES" << std::endl; // }else{ // std::cout << "NO" << std::endl; // } } return 0; }