307779: CF1415F. Cakes for Clones
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Cakes for Clones
题意翻译
一条数轴上有一个人,他的移动速度为 $1$,每个时刻他可以让自己的坐标从 $x$ 变为 $x\pm1$、或者保持 $x$ 不变。 当他位于整点上时,他可以放置一个无法移动的分身,同时摧毁已经存在的分身(如果存在),放置分身不消耗时间。 初始时他位于 $0$,现在有 $n$ 个任务,每个任务 $(x_i,t_i)$ 要求他在 $t_i$ 时刻要么本人要么分身在 $x_i$ 坐标处。 问是否存在合法方案,存在输出 `YES`,否则输出 `NO`。题目描述
You live on a number line. You are initially (at time moment $ t = 0 $ ) located at point $ x = 0 $ . There are $ n $ events of the following type: at time $ t_i $ a small cake appears at coordinate $ x_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 $ 1 $ 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 $ t $ , the old clone can collect the cakes that appear before or at the time moment $ t $ , and the new clone can collect the cakes that appear at or after time moment $ t $ . Can you collect all the cakes (by yourself or with the help of clones)?输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1 \le n \le 5000 $ ) — the number of cakes. Each of the next $ n $ lines contains two integers $ t_i $ and $ x_i $ ( $ 1 \le t_i \le 10^9 $ , $ -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.
输出格式
Print "YES" if you can collect all cakes, otherwise print "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