#include #include #include #include #include #define UINT uint64_t int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); // Tone range -> has lower tone (is invalid) //std::map, bool> redd; UINT n = 0, q = 0, s = 0, f = 0; std::cin >> n >> q; int64_t tones[n]; // Init values for (UINT i = 0; i < n; i++) std::cin >> tones[i]; for (UINT i = 0; i < q; i++) { bool isLowerTone = false; std::cin >> s >> f; if (s == f) { std::cout << "YES" << std::endl; continue; } int64_t prev = 0; for (UINT j = s; j < f; j++) { prev = tones[j - 1]; //std::cout << "Prev: " << prev << " Current" if (tones[j] < prev) { isLowerTone = true; break; } } if (isLowerTone) { std::cout << "NO" << std::endl; //resolved.set({s, f}, true); } else { std::cout << "YES" << std::endl; } } return 0; } /* int main() { UINT n = 0, q = 0, s = 0, f = 0; std::cin >> n >> q; int64_t tones[n]; // Init values for (UINT i = 0; i < n; i++) std::cin >> tones[i]; for (UINT i = 0; i < q; i++) { bool isLowerTone = false; std::cin >> s >> f; if (s == f) { std::cout << "YES" << std::endl; continue; } int64_t prev = tones[s - 1]; for (UINT j = s; j < f; j++) { if (tones[j] < prev) { std::cout << "NO" << std::endl; break; } prev = tones[j]; //std::cout << "Prev: " << prev << " Current" if (tones[j] < prev) { isLowerTone = true; break; } if (j == f - 1) std::cout << "YES" << std::endl; } } return 0; } */