luogu#P5097. [USACO04OPEN] Cave Cows 2
[USACO04OPEN] Cave Cows 2
Problem Description
There is a long passage in a cave. It is made up of segments () connected end to end, numbered .
Each segment has a threshold value in the range . If a cow passes through segments in order, then the cow’s weight index must not exceed the minimum threshold among segments . Bessie has questions () and wants to ask you for the minimum threshold value from segment to segment .
Input Format
The first line contains and .
The next lines contain the threshold value of each segment. After that, the next lines each contain two integers, corresponding to and in the questions ().
Output Format
For each query, output the answer.
10 4
75
30
100
38
50
51
52
20
81
5
1 10
3 5
6 9
8 10
5
38
20
5
Hint
Translated by ChatGPT 5