A9393 | Crash
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line of the input contains an integer $n$ ( $1<=n<=10^{5}$ ) — the number of solutions. Each of the following $n$ lines contains two integers separated by space $x$ and $k$ ( $0<=x<=10^{5}$ ; $1<=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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted