#P7908. [Ynoi2005] qwq
[Ynoi2005] qwq
Problem Description
Define the initial sequence as a sequence in which every number is .
Define one operation as increasing the value of every number in an interval of the sequence by , with the restriction that the length of this interval cannot exceed .
Given a sequence of length , where the -th number is .
You need to answer queries. In each query, you are given , and you need to output the minimum number of operations required to turn an initial sequence of length into the subarray of (that is, the sequence ).
Input Format
The first line contains three integers .
The second line contains integers, where the -th is .
The next lines each contain two integers .
Output Format
Output lines, each containing one integer, indicating the minimum number of operations.
5 4 1
1 1 2 1 1
1 5
2
10 3 3
4 8 1 2 9 7 4 1 3 5
1 10
3 8
5 5
22
10
9
Hint
"Sample 1 Explanation"
An initial sequence of length is .
In the first operation, increase every number in the interval , that is, the st, nd, and rd numbers, by . After this operation, the sequence becomes .
In the second operation, increase every number in the interval , that is, the rd, th, and th numbers, by . After this operation, the sequence becomes .
"Constraints and Notes"
- Subtask 1 (1 point): .
- Subtask 2 (4 points): .
- Subtask 3 (10 points): .
- Subtask 4 (10 points): .
- Subtask 5 (15 points): .
- Subtask 6 (15 points): .
- Subtask 7 (20 points): .
- Subtask 8 (25 points): no special constraints.
For of the testdata, it is guaranteed that , , , and .
Translated by ChatGPT 5