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
  1. 2
    0 1
    1 1
Output
  1. YES
Input
  1. 4
    0 1
    1 2
    1 1
    0 2
Output
  1. NO
Input
  1. 4
    0 1
    1 1
    0 1
    0 2
Output
  1. YES
  2.  
  3. 其实题目不难,理解后就是一个水题。
    如果代码不合理输出NO反则输出YES
    本菜鸟定义了一个结构体 x对应的是所交的代码数,y对应的是学号。
    (代码合理的条件:所交的代码数必须逐渐增加,必须从0开始,
    后面的对应学号的所交的代码数不能大于(0+1
    表达能力不是很好。
    下面放代码你们应该就可以很好的理解了。
  1. #include<cstdio>
  2. #include<cstring>
  3. #include<algorithm>
  4. using namespace std;
  5. struct node
  6. {
  7. int x,y;
  8. }qu[];
  9. int ans[];
  10. int main() {
  11. int n;
  12. while(scanf("%d",&n)!=EOF){
  13. for (int i= ;i< ;i++) ans[i]=-;
  14. memset(vis,,sizeof(vis));
  15. int flag=;
  16. for (int i= ;i<n ;i++){
  17. scanf("%d%d",&qu[i].x,&qu[i].y);
  18. if (ans[qu[i].y]+>=qu[i].x){
  19. if (qu[i].x==ans[qu[i].y]+) ans[qu[i].y]=qu[i].x;
  20. }else {
  21. flag=;
  22. }
  23. }
  24. if (flag) printf("YES\n");
  25. else printf("NO\n");
  26. }
  27. return ;
  28. }
  1.  

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. BZOJ 4078: [Wf2014]Metal Processing Plant [放弃了]

    以后再也不做$World Final$的题了................ 还我下午 bzoj上TLE一次后就不敢交了然后去uva交 Claris太神了代码完全看不懂 还有一个代码uva上竟然WA了 ...

  2. 输入url到渲染出页面的过程

    输入地址 浏览器查找域名的 IP 地址 这一步包括 DNS 具体的查找过程,包括:浏览器缓存->系统缓存->路由器缓存... 浏览器向 web 服务器发送一个 HTTP 请求 服务器的永久 ...

  3. I can do it

    If it doesn't challange you ,it won't change you.

  4. win7本地连接消失

    可能原因一 驱动程序错误: 右键"计算机"图标 - "属性" - 设备管理器现在在设备管理器下面找到"网络适配器",在下面的网卡驱动中发现有 ...

  5. [转]用JavaScript在浏览器中创建下载文件

    前端很多项目中,都有文件下载的需求,特别是JS生成文件内容,然后让浏览器执行下载操作(例如在线图片编辑.在线代码编辑.iPresst等. 但受限于浏览器,很多情况下我们都只能给出个链接,让用户点击打开 ...

  6. maven配置全局的jdk和配置局部的jdk

    配置全局的jdk需要修改maven的setting.xml文件 <profile> <id>jdk17</id> <activation> <ac ...

  7. zip-gzip-bzip2_压缩文件

    问:为什么要压缩文件? 答:方便传输,因为压缩的文件容量会比较小        存储所使用的空间也会比较小 ---> 备份   Windows里的压缩软件:WinRAR.Zip.好压.2345 ...

  8. WPF&Winform版本地图引擎

    最近几年一直从事地图方面的工作,自主研发了WPF和Winform两个版本瓦片地图引擎.轻量级.不依赖第三库.先上一张图片展示一下吧! 产品包括服务端和客户端两部份: 1.服务端主要地图图层配制和空间计 ...

  9. 流式计算与计算抽象化------《Designing Data-Intensive Applications》读书笔记15

    上篇的内容,我们探讨了分布式计算中的MapReduce与批处理.所以本篇我们将继续探索分布式计算优化的相关细节,并且分析MapReduce与批处理的局限性,看看流式计算是否能给我们在分布式计算层面提供 ...

  10. JSTL的相关使用

    index.jsp <%@ page language="java" import="java.util.*" pageEncoding="UT ...