#P3865. 【模板】ST 表 & RMQ 问题
【模板】ST 表 & RMQ 问题
Description
Given a sequence of length and queries, for each query, find the maximum number in the specified interval.
Input Format
The first line contains two integers , representing the length of the sequence and the number of queries.
The second line contains integers (denoted as ), representing the -th element of the sequence in order.
The next lines each contain two integers , indicating that the query interval is .
Output Format
Output lines, each containing one integer, representing the answer to each query in order.
8 8
9 3 1 7 5 6 0 8
1 6
1 5
2 7
2 6
1 8
4 8
3 7
1 8
9
9
7
7
9
8
7
9
Hint
- For 30% of the testdata, .
- For 70% of the testdata, .
- For 100% of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号