#P4215. 踩气球
踩气球
Description
Children’s Day has arrived, and SHUXK is forced to play a boring game with kids: there are boxes lined up from left to right, and the -th box contains balloons.
SHUXK will perform operations. In each operation, he takes one unpopped balloon from some box, and the kids immediately pop it.
Each of the kids has specified an interval of boxes . If at any moment a kid finds that all balloons in their chosen interval have been popped, they become very happy (and will remain happy thereafter).
To live up to the expectations of the person who dumped this task on SHUXK, he asks you:
- After each operation, how many kids are happy?
Input Format
The first line contains two positive integers and , the numbers of boxes and kids, respectively.
The second line contains positive integers (), the number of balloons in each box.
Each of the following lines contains two positive integers (), the interval specified by each kid.
The next line contains a positive integer , the number of operations SHUXK performs.
Each of the following lines contains a positive integer , indicating that this operation takes a balloon from the -th box. To enforce online queries, the input is encrypted.
Let the given positive integer be ; then the real , where is the answer to the previous query. For the first query, .
Output Format
Output lines. Each line should contain one integer, the answer to SHUXK’s question after a single operation. The answers must be in the same order as the input queries.
5 3
1 1 1 1 1
5 5
2 2
1 3
5
4
2
5
2
3
0
1
1
2
3
Hint
Constraints and Conventions
For all data, , , .
The testdata guarantees , and that the -th box always has at least one unpopped balloon.
Translated by ChatGPT 5
京公网安备 11011102002149号