#P8182. 「EZEC-11」雪的魔法
「EZEC-11」雪的魔法
Background
Muxii is a snow mage. As long as he waves his wand and chants a mysterious spell, snowflakes will fall from the sky and slowly build up a thick layer of snow on the ground. Because Muxii's magic is so powerful, God appointed Muxii to control all the snow in the world.
One day, God gave Muxii a task: he needs to make it snow on a piece of ground of length . The snow depth at position must reach (; “reach ” means it can be neither less than nor greater than ). However, what God does not know is that Muxii's ability is limited: each time he casts a spell, he can only make it snow for 1 second on an interval of length , increasing the snow depth in that interval by . Since the task is urgent, Muxii wants to know: to complete the task for some interval, how many spells does he need to cast at minimum?
Problem Description
Define the initial sequence as a sequence where every number is .
Define one operation as increasing every number in an interval of the sequence by , with the restriction that the length of the interval cannot exceed .
You are given a sequence of length , where the -th number is .
You need to answer queries. In each query, you are given . You need to output the minimum number of operations required to transform an initial sequence of length into of (that is, the sequence ).
Input Format
The first line contains three integers .
The second line contains integers, where the -th one is .
The next lines each contain two integers .
Output Format
Output lines, each containing one integer, 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 .
The first operation increases every number in interval , i.e. the st, nd, and rd numbers, by . After this operation, the sequence becomes .
The second operation increases every number in interval , i.e. 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 , , , .
Translated by ChatGPT 5