题库练习 Train Maintenance
← 上一题 下一题 →

A14664 | Train Maintenance

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Kawasiro Nitori is excellent in engineering. Thus she has been appointed to help maintain trains.

There are $n$ models of trains, and Nitori's department will only have at most one train of each model at any moment. In the beginning, there are no trains, at each of the following $m$ days, one train will be added, or one train will be removed. When a train of model $i$ is added at day $t$ , it works for $x_i$ days (day $t$ inclusive), then it is in maintenance for $y_i$ days, then in work for $x_i$ days again, and so on until it is removed.

In order to make management easier, Nitori wants you to help her calculate how many trains are in maintenance in each day.

On a day a train is removed, it is not counted as in maintenance.

输入格式

The first line contains two integers $n$ , $m$ ( $1 \le n,m \le 2 \cdot 10^5$ ).

The $i$ -th of the next $n$ lines contains two integers $x_i,y_i$ ( $1 \le x_i,y_i \le 10^9$ ).

Each of the next $m$ lines contains two integers $op$ , $k$ ( $1 \le k \le n$ , $op = 1$ or $op = 2$ ). If $op=1$ , it means this day's a train of model $k$ is added, otherwise the train of model $k$ is removed. It is guaranteed that when a train of model $x$ is added, there is no train of the same model in the department, and when a train of model $x$ is removed, there is such a train in the department.

输出格式

Print $m$ lines, The $i$ -th of these lines contains one integers, denoting the number of trains in maintenance in the $i$ -th day.

输入输出样例

输入 #1
3 4
10 15
12 10
1 1
1 3
1 1
2 1
2 3
输出 #1
0
1
0
0
输入 #2
5 4
1 1
10000000 100000000
998244353 1
2 1
1 2
1 5
2 5
1 5
1 1
输出 #2
0
0
0
1
C++ 编辑器
输入
输出