#include #include #include #include #include #include #include #include //#include std::vector, bool>> g_previous; //int g_no_previous = 0; bool test_freq(int t_start, int t_end, std::vector& t_frequencies) { bool l_result = true; // previous intervals for (int l_idx = 0; l_idx < g_previous.size(); l_idx++) { std::pair, bool> l_previous = g_previous[l_idx]; std::pair l_query = l_previous.first; bool l_status = l_previous.second; if (t_start >= l_query.first && t_end <= l_query.second) { return l_status; } } std::pair l_indexes; l_indexes.first = t_start; l_indexes.second = t_end; std::pair, bool> l_current; l_current.first = l_indexes; // new interval for (int l_idx = t_start - 1; l_idx < t_end - 1; l_idx++) if (t_frequencies[l_idx] > t_frequencies[l_idx + 1]) { l_current.second = false; return false; } return l_result; } int main() { int l_no_freq, l_no_queries; std::cin >> l_no_freq >> l_no_queries; // in freq std::vector l_frequencies(l_no_freq); for (int l_idx = 0; l_idx < l_no_freq; l_idx++) { std::cin >> l_frequencies[l_idx]; } // queries for (int l_idx = 0; l_idx < l_no_queries; l_idx++) { int l_qstart, l_qend; std::cin >> l_qstart >> l_qend; if (test_freq(l_qstart, l_qend, l_frequencies)) { std::cout << "YES\n"; } else { std::cout << "NO\n"; } } }