CF1580C.Train Maintenance

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

There are nn 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 mm days, one train will be added, or one train will be removed. When a train of model ii is added at day tt, it works for xix_i days (day tt inclusive), then it is in maintenance for yiy_i days, then in work for xix_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.

河城荷取在工程学方面十分出色,因此被委任协助维护列车。

共有 nn 种型号的列车,而荷取所在的部门在任意时刻每种型号最多只拥有一列列车。初始时没有列车;在接下来的 mm 天中,每天将新增一列列车,或移除一列列车。当型号为 ii 的列车于第 tt 天加入时,它将工作 xix_i 天(包含第 tt 天),随后进入为期 yiy_i 天的维修期,接着再工作 xix_i 天,依此类推,直至该列车被移除。

为便于管理,荷取希望你帮她计算每一天处于维修状态的列车数量。

在列车被移除的当天,该列车不计入维修状态。

输入格式

The first line contains two integers nn, mm (1≤n,m≤2⋅1051 \le n,m \le 2 \cdot 10^5).

The ii-th of the next nn lines contains two integers xi,yix_i,y_i (1≤xi,yi≤1091 \le x_i,y_i \le 10^9).

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

第一行包含两个整数 nn、mm(1≤n,m≤2⋅1051 \le n,m \le 2 \cdot 10^5)。

接下来的 nn 行中,第 ii 行包含两个整数 xix_i、yiy_i(1≤xi,yi≤1091 \le x_i,y_i \le 10^9)。

接下来的 mm 行中,每行包含两个整数 opop、kk(1≤k≤n1 \le k \le n,且 op=1op = 1 或 op=2op = 2)。若 op=1op=1,表示当天新增一辆型号为 kk 的列车;否则(即 op=2op=2),表示当天移除一辆型号为 kk 的列车。保证:当型号为 xx 的列车被添加时,该部门中不存在同型号的列车;当型号为 xx 的列车被移除时,该部门中确实存在一辆同型号的列车。

输出格式

Print mm lines, The ii-th of these lines contains one integers, denoting the number of trains in maintenance in the ii-th day.

输出 mm 行,其中第 ii 行包含一个整数,表示第 ii 天处于维护状态的列车数量。

输入输出样例

  • 输入#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

说明/提示

Consider the first example:

The first day: Nitori adds a train of model 33. Only a train of model 33 is running and no train is in maintenance.

The second day: Nitori adds a train of model 11. A train of model 11 is running and a train of model 33 is in maintenance.

The third day: Nitori removes a train of model 11. The situation is the same as the first day.

The fourth day: Nitori removes a train of model 33. There are no trains at all.

考虑第一个例子:

第一天:Nitori 添加了一列型号为 33 的列车。此时仅有一列型号为 33 的列车在运行,且没有列车处于维修状态。

第二天:Nitori 添加了一列型号为 11 的列车。此时一列型号为 11 的列车在运行,而一列型号为 33 的列车处于维修状态。

第三天:Nitori 移除了一列型号为 11 的列车。此时的情形与第一天相同。

第四天:Nitori 移除了一列型号为 33 的列车。此时已没有任何列车。

输入解题思路,AI测评打分。不知道怎么写?

首页