Static Range Minimum
Each query gives L and R and asks for the minimum of aL..R. There are many queries, so per-query scanning is too slow at the limits.
Input: the first line has N and Q; the second line has N integers; each of the next Q lines has L and R.
Output: Q lines — the range minimum per query.
Constraints:
- 1 ≤ N, Q ≤ 105
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
5 2 5 2 4 1 3 1 3 3 5
Output 1
2 1
Input 2
1 1 -5 1 1
Output 2
-5
Discussion (opens after you solve — no spoilers before)
No comments yet.