#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 [x, y] = range.first; if (x >= l && y <= r) { if (!range.second) 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; } } std::cout << "YES\n"; continue; smrt: std::cout << "NO\n"; } }