Submit solution
Points:
10
Time limit:
2.0s
PyPy 2
4.0s
PyPy 3
4.0s
Memory limit:
64M
PyPy 2
125M
PyPy 3
125M
Author:
Problem type
As a student, you're probably lazy. Realizing that,
has decided to decrease the word length of this problem and to keep it simple:Given an array with subarray queries, you are to find the maximum and minimum values of the subarrays, and output the difference of the two.
Note: Solutions that are unintended and pass will result in an attempt of
to create a test case that fails your solution.Constraints
The values of the array are positive integers that can be up to .
Input Specification
The first line contains two integers, and .
The next line contains integers, representing the values of the array in order (from to ).
The last lines will contain two integers, and , the 1-indexed query.
Output Specification
For each query, output the maximum number in the subarray - the minimum number in the subarray.
Sample Input 1
6 4
1 3 9 4 3 5
1 2
2 5
4 6
4 5
Sample Output 1
2
6
2
1
Comments