#Q121. 「一本通 4.2 例 1」数列区间最大值
「一本通 4.2 例 1」数列区间最大值
Description
Given a sequence of numbers, you will receive queries. Each query provides two numbers and , and you need to determine the maximum number in the interval from to .
Input Format
The first line contains two integers and , representing the number of elements and the number of queries, respectively.
The next line contains numbers.
The following lines each contain two integers and .
Output Format
Output lines, each containing the answer to the corresponding query.
Sample 1
10 2
3 2 4 5 6 8 1 2 9 7
1 4
3 8
5
8
Constraints and Hints
For all data, , , . The numbers do not exceed the int range in C/C++.