CF417B.Crash

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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 kk , and each sent solution AA is characterized by two numbers: xx — the number of different solutions that are sent before the first solution identical to AA , and kk — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same xx .

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 xx (x>0) of the participant with number kk , then the testing system has a solution with number x1x-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 nn ( 1<=n<=1051<=n<=10^{5} ) — the number of solutions. Each of the following nn lines contains two integers separated by space xx and kk ( 0<=x<=1050<=x<=10^{5} ; 1<=k<=1051<=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
    
首页