Service Lane
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
8 5
2 3 1 2 3 2 3 3
0 3
4 6
6 7
3 5
0 7
Caso de ejemplo — tu programa lee de stdin e imprime en stdout.
Service lane has varying widths. For each query (entry i, exit j), find minimum width in segment [i,j]. Output the largest vehicle type that can pass: 1=bike, 2=car, 3=truck.
Example: widths=[2,3,1,2,3,2,3,3], query [0,3] → min width in [2,3,1,2] is 1 → Output: 1 (only bike can pass)
Formato de entrada
First line: n t (space-separated). Second line: n space-separated integers (widths). Next t lines: i j (space-separated, entry and exit indices).
Formato de salida
For each query, output the maximum vehicle type (1, 2, or 3) that can pass.
Restricciones
2 ≤ n ≤ 10⁵, 1 ≤ t ≤ 1000, 1 ≤ width[i] ≤ 3, 0 ≤ i ≤ j < n