#include #include #include #include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::string line; int n,q; std::cin >> n >> q; std::cin.get(); std::vector seq; seq.reserve(n); std::getline(std::cin, line); std::istringstream iss(line); for (int i = 0; i < n; ++i) { int f; iss >> f; seq.emplace_back(f); } // std::map, bool> map; for (int i = 0; i < q; ++i) { int l, r; std::cin >> l >> r; // int small = seq[l-1]; // for (auto range : map) { // auto [range_low, range_high] = range.first; // if (l <= range_low && range_high <= r) { // if (!range.second) { //// std::cout << "here "; // goto smrt; // } // } // } // for (int j = l; j < r; ++j) { // if (seq[j-1] < small) { small = seq[j - 1]; } // // if (small > seq[j]) { // map[{l,r}] = false; // goto smrt; // } // } for (int j = l; j < r; ++j) { if (seq[j-1] > seq[j]) goto smrt; } std::cout << "YES\n"; continue; smrt: std::cout << "NO\n"; } }