302186: CF417B. Crash

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Crash

题意翻译

### 题目描述 在“俄罗斯代码杯”编程比赛的期间,代码测试系统储存了每一位参赛者发送的所有程序,有很多参赛者会在他们自己的代码程序中使用随机数,并发送几个具有相同的的程序。 每个参赛者由一个唯一的正整数 $k$ 来标识,每个发送的程序 $A$ 都由两个数字表示:$x$,在与 $A$ 相同的第一个程序之前发送的不同的程序的数量;$k$,参赛者的编号,即程序的作者。因此,所有相同的程序具有相同的 $x$。 众所周知,测试系统中的数据是按照时间顺序来存储的,就是说,如果测试系统有一个数字为 $x$($x \ge 0$)的程序,而参赛者的编号为 $k$,那么测试系统有一个编号为 $x - 1$ 的程序存储在以前的某个地方。 比赛期间,测试系统崩溃了,但随后所有的参赛者提交的数据都已经恢复了。现在的陪审团想核实恢复的数据是否按照时间顺序储存, 请你帮助陪审团这样做。 ### 输入格式 第一行一个整数 $n$ $(1 \le n \le 10^{5})$,以下 $n$ 行分别是两个整数 $x$ $(0 \le x \le 10^{5})$ 和 $k$ $(1 \le k \le 10^{5})$。 它们分别表示: - $x$,在与 $A$ 相同的第一个程序之前发送的不同程序的数量。 - $k$,参赛者的编号,即程序的作者。 ### 输出格式 如果数据是按照顺序输入的, 则输出 `YES`; 反之, 输出 `NO` 。

题目描述

During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check. Each participant is identified by some unique positive integer $ k $ , and each sent solution $ A $ is characterized by two numbers: $ x $ — the number of different solutions that are sent before the first solution identical to $ A $ , and $ k $ — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same $ x $ . It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number $ x $ $ (x>0) $ of the participant with number $ k $ , then the testing system has a solution with number $ x-1 $ of the same participant stored somewhere before. During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.

输入输出格式

输入格式


The first line of the input contains an integer $ n $ ( $ 1<=n<=10^{5} $ ) — the number of solutions. Each of the following $ n $ lines contains two integers separated by space $ x $ and $ k $ ( $ 0<=x<=10^{5} $ ; $ 1<=k<=10^{5} $ ) — the number of previous unique solutions and the identifier of the participant.

输出格式


A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.

输入输出样例

输入样例 #1

2
0 1
1 1

输出样例 #1

YES

输入样例 #2

4
0 1
1 2
1 1
0 2

输出样例 #2

NO

输入样例 #3

4
0 1
1 1
0 1
0 2

输出样例 #3

YES

Input

题意翻译

### 题目描述 在“俄罗斯代码杯”编程比赛的期间,代码测试系统储存了每一位参赛者发送的所有程序,有很多参赛者会在他们自己的代码程序中使用随机数,并发送几个具有相同的的程序。 每个参赛者由一个唯一的正整数 $k$ 来标识,每个发送的程序 $A$ 都由两个数字表示:$x$,在与 $A$ 相同的第一个程序之前发送的不同的程序的数量;$k$,参赛者的编号,即程序的作者。因此,所有相同的程序具有相同的 $x$。 众所周知,测试系统中的数据是按照时间顺序来存储的,就是说,如果测试系统有一个数字为 $x$($x \ge 0$)的程序,而参赛者的编号为 $k$,那么测试系统有一个编号为 $x - 1$ 的程序存储在以前的某个地方。 比赛期间,测试系统崩溃了,但随后所有的参赛者提交的数据都已经恢复了。现在的陪审团想核实恢复的数据是否按照时间顺序储存, 请你帮助陪审团这样做。 ### 输入格式 第一行一个整数 $n$ $(1 \le n \le 10^{5})$,以下 $n$ 行分别是两个整数 $x$ $(0 \le x \le 10^{5})$ 和 $k$ $(1 \le k \le 10^{5})$。 它们分别表示: - $x$,在与 $A$ 相同的第一个程序之前发送的不同程序的数量。 - $k$,参赛者的编号,即程序的作者。 ### 输出格式 如果数据是按照顺序输入的, 则输出 `YES`; 反之, 输出 `NO` 。

加入题单

算法标签: