AT_abc457_g.Catch All Apples

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

NN apples fall on a number line. Apple ii falls at coordinate XiX_i at time TiT_i.

You want to place some robots on the number line to collect all NN apples. The robots can be placed at any coordinates.

Each robot starts operating from time 00 and can move freely along the number line at a speed of at most 11. Multiple robots may occupy the same coordinate at the same time. Each robot can collect apple ii if and only if it is at coordinate XiX_i at time TiT_i.

Find the minimum number of robots needed to collect all apples.

有 NN 个苹果落在一条数轴上。苹果 ii 在时刻 TiT_i 落在坐标 XiX_i 处。

你想在数轴上放置若干机器人来收集全部 NN 个苹果。机器人可以放置在任意坐标处。

每个机器人从时刻 00 开始工作,且沿数轴移动的速度至多为 11。多个机器人可以在同一时刻位于同一坐标。机器人当且仅当在时刻 TiT_i 恰好位于坐标 XiX_i 时,才能收集苹果 ii。

求收集全部苹果所需的最少机器人数量。

输入格式

The input is given from Standard Input in the following format:

NN
T1T_1 X1X_1
T2T_2 X2X_2
⋮\vdots
TNT_N XNX_N

输入从标准输入中按以下格式给出:

NN
T1T_1 X1X_1
T2T_2 X2X_2
⋮\vdots
TNT_N XNX_N

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    4
    0 2
    1 0
    2 1
    2 3

    输出#1

    2
  • 输入#2

    5
    0 1
    0 2
    0 3
    0 4
    0 5

    输出#2

    5
  • 输入#3

    8
    10 4
    4 2
    7 10
    5 3
    1 9
    0 6
    3 8
    0 9

    输出#3

    2

说明/提示

Sample 1 Explanation:
All apples can be collected with two robots by moving them as follows:

  • Place robot 11 at coordinate 00 and robot 22 at coordinate 22.
  • Time 00: Robot 22 collects apple 11.
  • Time 11: Robot 11 collects apple 22. Move both robots in the positive direction at speed 11 until time 22.
  • Time 22: Robot 11 collects apple 33 and robot 22 collects apple 44.

It is impossible to collect all apples with fewer than two robots, so output 22.

Constraints

  • 1≤N≤3×1051 \le N \le 3 \times 10^5
  • 0≤Ti≤3×1050 \le T_i \le 3 \times 10^5
  • 0≤Xi≤3×1050 \le X_i \le 3 \times 10^5
  • (Ti,Xi)≠(Tj,Xj)(T_i, X_i) \neq (T_j, X_j) (i≠j)(i \neq j)
  • All input values are integers.

样例 1 解释:
所有苹果均可由两个机器人协作收集,具体移动方式如下:

  • 将机器人 11 置于坐标 00 处,机器人 22 置于坐标 22 处。
  • 时刻 00:机器人 22 收集苹果 11。
  • 时刻 11:机器人 11 收集苹果 22;此后两机器人均以速度 11 向正方向移动,持续至时刻 22。
  • 时刻 22:机器人 11 收集苹果 33,机器人 22 收集苹果 44。

无法用少于两个机器人收集全部苹果,因此输出 22。

约束条件

  • 1≤N≤3×1051 \le N \le 3 \times 10^5
  • 0≤Ti≤3×1050 \le T_i \le 3 \times 10^5
  • 0≤Xi≤3×1050 \le X_i \le 3 \times 10^5
  • (Ti,Xi)≠(Tj,Xj)(T_i, X_i) \neq (T_j, X_j)(当 i≠ji \neq j 时)
  • 所有输入值均为整数。

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

首页