#x1039. CF1580C Train Maintenance
CF1580C Train Maintenance
Train Maintenance
题面翻译
题目描述:
有 种列车,第 种列车每工作 天就要维护 天。
接下来的 天中,每天有一个操作,分为加入一列车和删除一列车。在车刚加入的那一天,它刚维修完,即加进来的那天可以正常工作。
每一天的操作完成后,你都要回答,当前有多上车在维修?
输入格式
第一行两个整数 。
接下来 行,第 行每行两个整数 。
接下来 行,每行两个正整数 ,描述当天的操作:
若 ,表示加入一列 种类的车,保证当前没有 种类的车;
若 ,表示删除一辆 种类的车,保证当前有且仅有一列 种类的车。
输出格式
行,表示每组询问的答案。
数据范围:
。
。
或 。
。
题目描述
Kawasiro Nitori is excellent in engineering. Thus she has been appointed to help maintain trains.
There are 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 days, one train will be added, or one train will be removed. When a train of model is added at day , it works for days (day inclusive), then it is in maintenance for days, then in work for 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 , ( ).
The -th of the next lines contains two integers ( ).
Each of the next lines contains two integers , ( , or ). If , it means this day's a train of model is added, otherwise the train of model is removed. It is guaranteed that when a train of model is added, there is no train of the same model in the department, and when a train of model is removed, there is such a train in the department.
输出格式
Print lines, The -th of these lines contains one integers, denoting the number of trains in maintenance in the -th day.
样例 #1
样例输入 #1
3 4
10 15
12 10
1 1
1 3
1 1
2 1
2 3
样例输出 #1
0
1
0
0
样例 #2
样例输入 #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
提示
Consider the first example:
The first day: Nitori adds a train of model . Only a train of model is running and no train is in maintenance.
The second day: Nitori adds a train of model . A train of model is running and a train of model is in maintenance.
The third day: Nitori removes a train of model . The situation is the same as the first day.
The fourth day: Nitori removes a train of model . There are no trains at all.