CF417B.Crash

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

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 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.

在“俄罗斯编程杯”(Russian Code Cup)编程竞赛中,评测系统会为每位参赛者存储其提交的所有程序代码。我们了解到,许多参赛者会在程序中使用随机数,因此常常会多次提交完全相同的源代码,以进行测试。

每位参赛者由一个唯一的正整数 kk 标识;而每次提交的程序 AA 则由两个数刻画:xx —— 在首次出现与 AA 完全相同的提交之前,该参赛者已提交的不同程序的数量;以及 kk —— 提交该程序的参赛者编号。因此,所有内容完全相同的提交具有相同的 xx 值。

已知评测系统中的数据按时间顺序(即提交发生的先后顺序)存储。也就是说,若评测系统中存在某位编号为 kk 的参赛者的、编号为 xx(其中 x>0x > 0)的提交,则在该提交之前,评测系统中必已存在该参赛者编号为 x−1x-1 的提交。

比赛期间评测系统曾发生崩溃,但之后所有参赛者的提交数据均已恢复。现在,裁判组希望验证所恢复的数据是否仍保持正确的时间顺序。请帮助裁判组完成此项验证。

输入格式

The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.

输入的第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5)—— 解的数量。接下来的 nn 行中,每行包含两个由空格分隔的整数 xx 和 kk(0≤x≤1050 \leq x \leq 10^5;1≤k≤1051 \leq k \leq 10^5)—— 分别表示该参与者之前已有的唯一解的数量及其标识符。

输出格式

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

输出的单行中,如果数据按时间顺序排列,则应包含「YES」;否则为「NO」。

输入输出样例

  • 输入#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

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

首页