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.

Input

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.

Output

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

Example

Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES

其实题目不难,理解后就是一个水题。
如果代码不合理输出NO反则输出YES
本菜鸟定义了一个结构体 x对应的是所交的代码数,y对应的是学号。
(代码合理的条件:所交的代码数必须逐渐增加,必须从0开始,
后面的对应学号的所交的代码数不能大于(0+1)
表达能力不是很好。
下面放代码你们应该就可以很好的理解了。
 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
int x,y;
}qu[];
int ans[];
int main() {
int n;
while(scanf("%d",&n)!=EOF){
for (int i= ;i< ;i++) ans[i]=-;
memset(vis,,sizeof(vis));
int flag=;
for (int i= ;i<n ;i++){
scanf("%d%d",&qu[i].x,&qu[i].y);
if (ans[qu[i].y]+>=qu[i].x){
if (qu[i].x==ans[qu[i].y]+) ans[qu[i].y]=qu[i].x;
}else {
flag=;
}
}
if (flag) printf("YES\n");
else printf("NO\n");
}
return ;
}

Crash CodeForces - 417B的更多相关文章

  1. CodeForces - 417B (思维题)

    Crash Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  2. 【codeforces 750D】New Year and Fireworks

    time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard ...

  3. 【腾讯Bugly干货分享】聊聊苹果的Bug - iOS 10 nano_free Crash

    本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:https://mp.weixin.qq.com/s/hnwj24xqrtOhcjEt_TaQ9w 作者:张 ...

  4. iOS 10 开发适配系列 之 权限Crash问题

    升级 iOS 10 之后目测坑还是挺多的,记录一下吧,看看到时候会不会成为一个系列. 直入正题吧 今天用一个项目小小练下手,发现调用相机,崩了.试试看调用相册,又特么崩了.然后看到控制台输出了以下信息 ...

  5. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  6. BZOJ 2154: Crash的数字表格 [莫比乌斯反演]

    2154: Crash的数字表格 Time Limit: 20 Sec  Memory Limit: 259 MBSubmit: 2924  Solved: 1091[Submit][Status][ ...

  7. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  8. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  9. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

随机推荐

  1. R语言-选择样本数量

    功效分析:可以帮助在给定置信度的情况下,判断检测到给定效应值时所需的样本量,也可以在给定置信水平的情况下,计算某样本量内可以检测到的给定效应值的概率 1.t检验 案例:使用手机和司机反应时间的实验 l ...

  2. win7下MySQL的安装配置及卸载 笔记分享

    一.官网下载地址:https://dev.mysql.com/downloads/mysql/ 1.选择对应版本,下载免安装版: 2.不要注册账号,点击"No thanks,just sta ...

  3. 【翻译】我如何使用CSS来制作bitsofcode Logo动画

    翻译文章,翻译不好,还望大家指出 原文地址:How I Animated the bitsofcode Logo with CSS 我是css动画的新手,这样说是因为我只在有限的案例中使用过他们,而且 ...

  4. WPF DataTriger 用法示例代码

    用法1: <DataGridTemplateColumn Header="{lex:LocText ExamineRoom}"> <DataGridTemplat ...

  5. github上fork了别人的项目后,再同步更新别人的提交

    我从github网站和用Git命令两种方式说一下. github网站上操作 打开自己的仓库,进入code下面. 点击new pull request创建.  选择base fork 选择head fo ...

  6. Go学习笔记03-附录

    第三部分 附录 A. 工具 1. 工具集 1.1 go build gcflags ldflags 更多参数: go tool 6g -h 或 [https://golang.org/cmd/gc/] ...

  7. 收藏清单: python测试框架最全资源汇总

    xUnit frameworks 单元测试框架 frameworks 框架 unittest - python自带的单元测试库,开箱即用 unittest2 - 加强版的单元测试框架,适用于Pytho ...

  8. Windows系统上FFMpeg-PHP的使用

    这几天做项目,其中一个需求是用户上传视频文件到服务器,然后服务器自动截取该视频的一帧作为该视频对应的缩略图,服务器端语言采用php编写,找了半天资料,发现ffmpeg-php可以满足该需求,所以下面简 ...

  9. swap分区的扩展

    Linux中Swap(即:交换分区),类似于Windows的虚拟内存,就是当内存不足的时候,把一部分硬盘空间虚拟成内存使用,从而解决内存容量不足的情况.swap分区在非高内存的服务器上必不可少,但是s ...

  10. python 常见错误和异常 函数 正则表达式及多线程编程

    生成随机密码#!/usr/bin/env python import stringfrom random import choice def gen_pass(num=9): all_chs = st ...