#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); } for (int i = 0; i < q; ++i) { int l, r; std::cin >> l >> r; // std::cin.get(); int small = seq[l-1]; for (int j = l; j < r; ++j) { if (seq[j-1] < small) small = seq[j-1]; // std::cout << "small " << small << "\n"; // std::cout << "seq[j] " << seq[j] << "\n"; if (small > seq[j]) { goto smrt; } } std::cout << "YES\n"; continue; smrt: std::cout << "NO\n"; } }