#P5926. [JSOI2009] 面试的考验
[JSOI2009] 面试的考验
Description
For each query, find the absolute difference between two numbers in the given interval that are the closest to each other and are not equal.
Note: “Closest” means closest in value.
Input Format
The first line contains two integers , representing the length of the sequence and the number of queries.
The second line contains positive integers separated by spaces, representing the entire sequence, numbered from left to right as .
The next lines each contain two integers , representing a query interval.
The input guarantees that .
Output Format
For each query, output one line: the absolute difference between the two closest (and unequal) numbers in the queried interval.
5 3
1 4 2 6 7
2 3
3 4
2 5
2
4
1
Hint
For of the data, , .
The testdata is generated entirely purely at random.
Translated by ChatGPT 5
京公网安备 11011102002149号