#Lutece3032. Overkill for AK Prevention
Overkill for AK Prevention
Migrated from Lutece 3032 Overkill for AK Prevention
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
For a sequence of length , each time you can choose a subinterval , and subtract from each number () in this subinterval (note that it is not allowed to reduce any number to a negative number). At least how many operations are required to reduce all numbers in the sequence to ? - This is a classic problem solved by difference.
Now let's upgrade: we stipulate that the length of the interval selected each time cannot exceed , that is, .
Now let's upgrade it again: given a sequence of length , you need to answer queries, and each query is of the form , meaning that you need to calculate the answer to the above question for the subsequence .
Can you do it?
Input
The first line contains three integers , respectively representing the length of the sequence , The maximum length of the interval allowed for each operation, and the number of inquiries;
The second line contains integers representing the sequence ;
Then line follows, where the -th line contains two integers , denoting the queried subinterval.
Output
A total of rows, where the -th row contains an integer representing the answer to the -th query.
Samples
4 3 1
1 2 1 1
1 4
2
6 2 3
1 1 4 5 1 4
1 4
3 6
1 6
6
9
10