CF1887D Split
Description
Let's call an array $ b_1, b_2, \ldots, b_m $ ( $ m \ge 2 $ ) good if it can be split into two parts such that all elements in the left part are strictly smaller than all elements in the right part. In other words, there must exist an index $ 1 \le i < m $ such that every element from $ b_1, \ldots, b_i $ is strictly smaller than every element from $ b_{i+1}, \ldots, b_m $ .
Given an array $ a_1, a_2, \ldots a_n $ consisting of distinct integers from $ 1 $ to $ n $ . There are $ q $ queries. Each query consists of two numbers $ l $ and $ r $ . For each query, determine whether the array $ a_l, a_{l+1}, \ldots, a_r $ is good.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first example:
- The array $ [3,2,1,4,5] $ can be split into two parts: $ [3,2,1] $ and $ [4,5] $ .
- The array $ [3,2,1] $ cannot be split into two parts such that all elements in the left part are smaller than all elements in the right part.
- The array $ [3,2,1,4] $ can be split into two parts: $ [3,2,1] $ and $ [4] $ .
- The array $ [3,2] $ cannot be split into two parts such that all elements in the left part are smaller than all elements in the right part.
- The array $ [2,1,4,5] $ can be split into two parts: $ [2,1] $ and $ [4,5] $ .
In the second example:
- The array $ [2,4,3] $ can be split into two parts: $ [2] $ and $ [4,3] $ .
- The array $ [6,2,4,3,5] $ cannot be split into two parts such that all elements in the left part are smaller than all elements in the right part.
- The array $ [4,3,5] $ can be split into two parts: $ [4,3] $ and $ [5] $ .