CodeForces - 417B (思维题)
| Time Limit: 1000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
Description
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 numberx(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.
Sample Input
2
0 1
1 1
YES
4
0 1
1 2
1 1
0 2
NO
4
0 1
1 1
0 1
0 2
YES
Source
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int a[];
int main()
{
int i,n,m,x,k;
while(cin>>n)
{
int flag=;
memset(a,-,sizeof(a));
for (i=;i<n;i++)
{
cin>>x>>k;
if (a[k]+<x)
flag=;
a[k]=max(a[k],x);
}
if (flag)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
}
return ;
}
CodeForces - 417B (思维题)的更多相关文章
- Codeforces 424A (思维题)
Squats Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Statu ...
- Vova and Trophies CodeForces - 1082B(思维题)
Vova has won nn trophies in different competitions. Each trophy is either golden or silver. The trop ...
- CodeForces - 417A(思维题)
Elimination Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- B - Sonya and Exhibition CodeForces - 1004B (思维题)
B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input stand ...
- codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...
- 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...
- C. Nice Garland Codeforces Round #535 (Div. 3) 思维题
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- CodeForces - 631C ——(思维题)
Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...
- CodeForces - 1102A(思维题)
https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...
随机推荐
- angularjs的页面拆分思想
//app.js angular.module('MyModule', ['SubModule1', 'SubModule2']) .module('SubModule1', ['CommonModu ...
- HDU1907 John
Description Little John is playing very funny game with his younger brother. There is one big box fi ...
- 使用python来调试串口
串口模块的波特率比较特别,找了几个串口工具都不支持...所以,干脆用python自己来写了,其实已经好奇好久了,别人的工具各种不顺手. 需要pyserial的支持,兼容各种平台,不需要新编译二进制文件 ...
- 数组实现栈的结构(java)
自定义数组实现栈的结构. package test; public class MyArrayStackClient { public static void main(String[] args) ...
- VMware 11安装Mac OS X 10.11.5虚拟机以及优化心得
随着苹果WWC大会退出了MAC最新版的10.11.5,本着一颗“极客”的心情,在第一时间用VMWARE虚拟机装上了.然后各种卡顿这里分享一下优化mac虚拟机的心得. 1 从Dock上移除Dashboa ...
- c++11新特性(了解)
从C++出来到现在已经13年了. Bjarne Stroustrup(C++的创造者)最近评价C++:”感觉像个新的语言“. 事实上,C++11核心已经发生了很重大的变化: . 支持Lambda表达式 ...
- javaweb学习总结(三十)——EL函数库
一.EL函数库介绍 由于在JSP页面中显示数据时,经常需要对显示的字符串进行处理,SUN公司针对于一些常见处理定义了一套EL函数库供开发者使用. 这些EL函数在JSTL开发包中进行描述,因此在JSP页 ...
- sql 语句:给 text 数据类型排序
sql 语句: select * from 表 order by cast(字段 as varchar)
- Swift翻译之-关于Swift
IMPORTANT 重要的 This is a preliminary document for an API or technology in development. Apple is suppl ...
- wireshark基本用法及过虑规则
wireshark基本用法及过虑规则 标签: wireshark基本语法wireshark使用方法wireshark包过虑规则 2015-02-03 18:44 10711人阅读 评论(0) 收藏 ...