#include using namespace std; using ll = long long; using ull = unsigned long long; struct node { int start; int end; bool is; bool operator<(const node& other) const{ if(start == other.start){ return end < other.end; } return start < other.start; } bool operator==(const node& other)const { return (start == other.start) && (end == other.end); } }; void solve() { set set; int q, n; cin >> n >> q; int val, prev; for(int i = 0; i < n; i++){ if(i == 0) { cin >> val; node curr_node = { i+1, i+1, true }; //cout << curr_node.start << "," << curr_node.end << "," << curr_node.is << "\n"; set.insert(curr_node); } else { prev = val; cin >> val; node curr_node = { i+1, i+1, true }; //cout << curr_node.start << "," << curr_node.end << "," << curr_node.is << "\n"; set.insert(curr_node); node above = { i, i+1, prev <= val }; //cout << above.start << " " << above.end << " " << above.is << "\n"; //cout << prev << " " << val << " " << endl; set.insert(above); for(int j = i - 1; j >= 1; --j) { node l = { j, i, true }; node left = *set.find(l); node r = { j + 1, i + 1, true }; //cout << left.start << "," << left.end << "," << left.is << "\n"; node right = *set.find(r); node to_insert = { left.start, right.end, right.is && left.is }; //cout << to_insert.start << "," << to_insert.end << "," << to_insert.is << "\n"; auto res = set.insert(to_insert); if(res.second == false) { cout << "Ins fail" << endl; } } } } for(int i = 0; i < q; ++i) { int s, e; cin >> s >> e; auto x = set.find({ s, e, true }); if(x != set.end()){ //cout << x->start << "," << x->end << "," << x->is << "\n"; if(x->is) { cout << "YES\n"; } else { cout << "NO\n"; } } else { cout << "NOTFOUND\n"; } } } int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); return 0; }