8822: [yosupo] Data Structure - Static RMQ
[Creator : ]
Description
You are given an integer sequence $a_0, a_1, ..., a_{N-1}$ with the length $N$.
Process the following $Q$ queries in order:
- $l_i$ $r_i$: Print $\min(a_{l_i}, a_{l_i + 1}, ..., a_{r_i - 1})$.
Process the following $Q$ queries in order:
- $l_i$ $r_i$: Print $\min(a_{l_i}, a_{l_i + 1}, ..., a_{r_i - 1})$.
Input
$N$ $Q$
$a_0$ $a_1$ ... $a_{N - 1}$
$l_1$ $r_1$
$l_2$ $r_2$
:
$l_Q$ $r_Q$
$a_0$ $a_1$ ... $a_{N - 1}$
$l_1$ $r_1$
$l_2$ $r_2$
:
$l_Q$ $r_Q$
Constraints
$1 \leq N, Q \leq 500,000$
$0 \leq a_i \leq 10^9$
$0 \leq l_i < r_i \leq N$
$0 \leq a_i \leq 10^9$
$0 \leq l_i < r_i \leq N$
Sample 1 Input
4 10
2 10 1 100
0 1
0 2
0 3
0 4
1 2
1 3
1 4
2 3
2 4
3 4
Sample 1 Output
2
2
1
1
10
1
1
1
1
100