CF1852F.Panda Meetups

NOI/NOI+/CTSC

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The red pandas are in town to meet their relatives, the blue pandas! The town is modeled by a number line.

The pandas have already planned their meetup, but the schedule keeps changing. You are given qq updates of the form x t c.

  • If c<0c \lt 0, it means ∣c∣|c| more red pandas enter the number line at position xx and time tt. Then, each unit of time, they can each independently move one unit in either direction across the number line, or not move at all.
  • If c>0c \gt 0, it means that cc more blue pandas check position xx for red pandas at time tt. If a blue panda does not meet a red panda at that specific location and time, they dejectedly leave the number line right away. If there is a red panda at a position at the same time a blue panda checks it, they form a friendship and leave the number line. Each red panda can form a friendship with at most one blue panda and vice versa.

The updates will be given in order of non-decreasing xx values. After each update, please print the maximum number of friendships if the red pandas move in an optimal order based on all the updates given in the input above (and including) this update.

The order in which a red panda moves can change between updates.

红熊猫们来到小镇与它们的亲戚——蓝熊猫们会面!小镇被建模为一条数轴。

熊猫们已经规划好了会面,但日程却不断变化。你将收到 qq 个更新,每个更新形如 x t c:

  • 若 c<0c \lt 0,表示在位置 xx、时刻 tt 新增了 ∣c∣|c| 只红熊猫进入数轴。此后,每单位时间,每只红熊猫可独立地在数轴上向左或向右移动一个单位,或保持不动。
  • 若 c>0c \gt 0,表示在时刻 tt 有 cc 只蓝熊猫前往位置 xx 寻找红熊猫。若某只蓝熊猫在该特定位置与时刻未遇到任何红熊猫,则它会沮丧地立即离开数轴;若在该位置与时刻恰有红熊猫存在,则二者结为朋友并一同离开数轴。每只红熊猫最多与一只蓝熊猫结为朋友,反之亦然。

所有更新按 xx 值非递减顺序给出。在每次更新后,请输出:基于输入中截至(含)当前更新的所有更新信息,在红熊猫采取最优移动策略的前提下,所能达成的最大友谊对数。

红熊猫在不同更新之间的移动策略可以不同。

输入格式

The first line contains qq (1≤q≤2⋅1051 \leq q \leq 2 \cdot 10^5) – the number of updates.

The ii-th line of the next qq lines consists of 33 integers xix_i, tit_i and cic_i (0≤xi≤1090 \leq x_i \leq 10^9, 0≤ti≤1090 \leq t_i \leq 10^9, 0<∣ci∣≤10000 \lt |c_i| \leq 1000) – the description of the ii-th update.

It is guaranteed that the xix_i will be given in non-decreasing order.

第一行包含一个整数 qq(1≤q≤2⋅1051 \leq q \leq 2 \cdot 10^5),表示更新操作的次数。

接下来的 qq 行中,第 ii 行包含三个整数 xix_i、tit_i 和 cic_i(0≤xi≤1090 \leq x_i \leq 10^9,0≤ti≤1090 \leq t_i \leq 10^9,0<∣ci∣≤10000 \lt |c_i| \leq 1000),描述第 ii 次更新操作。

保证输入的 xix_i 是以非递减顺序给出的。

输出格式

After each update, print the maximum number of friendships that can be formed.

每次更新后,输出最多可以建立的友谊数量。

输入输出样例

  • 输入#1

    5
    0 6 3
    4 2 -5
    7 4 -6
    10 5 100
    10 8 7

    输出#1

    0
    3
    3
    3
    10
  • 输入#2

    5
    0 6 3
    4 2 -5
    7 4 -6
    10 5 100
    11 8 7

    输出#2

    0
    3
    3
    3
    9
  • 输入#3

    7
    0 8 6
    2 7 -2
    3 1 -6
    5 3 -8
    7 3 -3
    8 0 -2
    8 2 1

    输出#3

    0
    0
    6
    6
    6
    6
    7
  • 输入#4

    4
    0 0 -3
    0 0 2
    0 0 4
    0 0 -10

    输出#4

    0
    2
    3
    6

说明/提示

In the first example, the number of friendships after each update can be optimized as follows:

  1. 33 blue pandas now check for red pandas at position 00 at time 66. There are no red pandas anywhere, so there are no friendships.
  2. 55 red pandas now appear at position 44 and time 22. 44 of the red pandas can travel to position 00 at time 66, where 33 of them can make friendships with the 33 existing blue pandas.
  3. 66 red pandas now appear at position 77 and time 44. No new blue pandas are added, so the maximum number of friendships is still 33.
  4. 100100 blue pandas now appear at position 1010 and time 55. No red pandas can reach them at a time of 55, so no new friendships are created.
  5. 77 blue pandas now appear at position 1010 and time 88. 66 of the red pandas at position 77 and time 44, along with 11 red panda at position 44 and time 22, can reach 77 of the blue pandas at position 1010 at time 88, adding 77 new friendships. This brings the total to 1010 friendships.

在第一个样例中,每次更新后友谊的数量可按如下方式优化:

  1. 此时有 33 只蓝熊猫,在时刻 66、位置 00 处寻找红熊猫。此时任意位置均无红熊猫,因此不存在友谊。
  2. 此时有 55 只红熊猫在时刻 22、位置 44 处出现。其中 44 只红熊猫可于时刻 66 到达位置 00,并与已有的 33 只蓝熊猫中的 33 只建立友谊。
  3. 此时有 66 只红熊猫在时刻 44、位置 77 处出现。此步未新增蓝熊猫,因此友谊的最大数量仍为 33。
  4. 此时有 100100 只蓝熊猫在时刻 55、位置 1010 处出现。此时无红熊猫能在时刻 55 到达该位置,因此未产生新的友谊。
  5. 此时有 77 只蓝熊猫在时刻 88、位置 1010 处出现。位于时刻 44、位置 77 的 66 只红熊猫,以及位于时刻 22、位置 44 的 11 只红熊猫,均可于时刻 88 到达位置 1010,并与该处的 77 只蓝熊猫全部建立友谊,从而新增 77 对友谊。此时友谊总数达到 1010 对。

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

首页