CF1415F.Cakes for Clones

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You live on a number line. You are initially (at time moment t=0t = 0) located at point x=0x = 0. There are nn events of the following type: at time tit_i a small cake appears at coordinate xix_i. To collect this cake, you have to be at this coordinate at this point, otherwise the cake spoils immediately. No two cakes appear at the same time and no two cakes appear at the same coordinate.

You can move with the speed of 11 length unit per one time unit. Also, at any moment you can create a clone of yourself at the same point where you are located. The clone can't move, but it will collect the cakes appearing at this position for you. The clone disappears when you create another clone. If the new clone is created at time moment tt, the old clone can collect the cakes that appear before or at the time moment tt, and the new clone can collect the cakes that appear at or after time moment tt.

Can you collect all the cakes (by yourself or with the help of clones)?

你生活在一条数轴上。在初始时刻(t=0t = 0)你位于坐标 x=0x = 0 处。共有 nn 个事件,每个事件的形式为:在时刻 tit_i,坐标 xix_i 处会出现一块小蛋糕。要收集这块蛋糕,你必须恰好在时刻 tit_i 到达坐标 xix_i;否则蛋糕会立即变质。任意两个蛋糕不会在同一时刻出现,也不会出现在同一坐标处。

你的移动速度为每单位时间移动 1 个长度单位。此外,在任意时刻,你可以在自己当前所在位置创建一个自己的克隆体。该克隆体不能移动,但它能替你收集在该位置出现的蛋糕。当你创建一个新的克隆体时,旧的克隆体会立即消失。若新克隆体于时刻 tt 创建,则旧克隆体可收集所有出现时刻 ≤t\le t 的、位于其所在位置的蛋糕;而新克隆体则可收集所有出现时刻 ≥t\ge t 的、位于其所在位置的蛋糕。

你能否(通过自身或借助克隆体)收集全部蛋糕?

输入格式

The first line contains a single integer nn (1≤n≤50001 \le n \le 5000) — the number of cakes.

Each of the next nn lines contains two integers tit_i and xix_i (1≤ti≤1091 \le t_i \le 10^9, −109≤xi≤109-10^9 \le x_i \le 10^9) — the time and coordinate of a cake's appearance.

All times are distinct and are given in increasing order, all the coordinates are distinct.

第一行包含一个整数 nn(1≤n≤50001 \le n \le 5000)—— 蛋糕的数量。

接下来的 nn 行,每行包含两个整数 tit_i 和 xix_i(1≤ti≤1091 \le t_i \le 10^9,−109≤xi≤109-10^9 \le x_i \le 10^9)—— 分别表示第 ii 个蛋糕出现的时间和坐标。

所有时间互不相同,且按递增顺序给出;所有坐标互不相同。

输出格式

Print "YES" if you can collect all cakes, otherwise print "NO".

如果可以收集所有蛋糕,则输出 "YES",否则输出 "NO"。

输入输出样例

  • 输入#1

    3
    2 2
    5 5
    6 1

    输出#1

    YES
  • 输入#2

    3
    1 0
    5 5
    6 2

    输出#2

    YES
  • 输入#3

    3
    2 1
    5 5
    6 0

    输出#3

    NO

说明/提示

In the first example you should start moving towards 55 right away, leaving a clone at position 11 at time moment 11, and collecting the cake at position 22 at time moment 22. At time moment 55 you are at the position 55 and collect a cake there, your clone collects the last cake at time moment 66.

In the second example you have to leave a clone at position 00 and start moving towards position 55. At time moment 11 the clone collects a cake. At time moment 22 you should create a new clone at the current position 22, it will collect the last cake in future. You will collect the second cake at position 55.

In the third example there is no way to collect all cakes.

在第一个例子中,你应该立即开始向位置 55 移动,在时刻 11 于位置 11 留下一个分身,并在时刻 22 到达位置 22 收集蛋糕。在时刻 55,你到达位置 55 并收集那里的蛋糕,而你的分身则在时刻 66 收集最后一个蛋糕。

在第二个例子中,你必须在位置 00 留下一个分身,然后开始向位置 55 移动。在时刻 11,该分身收集一个蛋糕。在时刻 22,你应在当前位置 22 创建一个新的分身,它将在未来收集最后一个蛋糕。你则会在位置 55 收集第二个蛋糕。

在第三个例子中,不存在收集所有蛋糕的方法。

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

首页