Codeforces 807 A Is it rated?
2 seconds
256 megabytes
standard input
standard output
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
6
3060 3060
2194 2194
2876 2903
2624 2624
3007 2991
2884 2884
rated
4
1500 1500
1300 1300
1200 1200
1400 1400
unrated
5
3123 3123
2777 2777
2246 2246
2246 2246
1699 1699
maybe
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
如果前后两个值有改变,输出rated
否则,如果序列非增,输出maybe
否则,输出unrated
#include<cstdio>
using namespace std;
int n,a[],b[],last=;
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d",&a[i],&b[i]);
if(a[i]!=b[i]) { printf("rated"); return ; }
}
for(int i=;i<=n;i++)
if(a[i]>a[i-]) { printf("unrated"); return ; }
printf("maybe"); return ;
}
WA1:错误代码:
原因:如果所有的a等于b,那么中间a也有可能大于上一个a
#include<cstdio>
using namespace std;
int n,a,b,last=5000;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&a,&b);
if(a!=b) { printf("rated"); return 0; }
if(a>last) { printf("unrated"); return 0; }
last=a;
}
printf("maybe"); return 0;
}
WA2:判断序列非增时,要从第2个开始,因为第1个前面是0,一定增
Codeforces 807 A Is it rated?的更多相关文章
- Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals)
Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) A.String Reconstruction B. High Load C ...
- 【codeforces 807A】Is it rated?
[题目链接]:http://codeforces.com/contest/807/problem/A [题意] 给你n个人在一场CF前后的rating值; 问你这场比赛是不是计分的 [题解] 如果有一 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)
http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...
- Codeforces 807 C. Success Rate
http://codeforces.com/problemset/problem/807/C C. Success Rate time limit per test 2 seconds memory ...
- Codeforces 807 B T-Shirt Hunt
B. T-Shirt Hunt http://codeforces.com/problemset/problem/807/B time limit per test 2 seconds memory ...
- codeforces 807 E. Prairie Partition(贪心+思维)
题目链接:http://codeforces.com/contest/807/problem/E 题意:已知每个数都能用x=1 + 2 + 4 + ... + 2k - 1 + r (k ≥ 0, 0 ...
- codeforces 807 D. Dynamic Problem Scoring(贪心+思维)
题目链接:http://codeforces.com/contest/807/problem/D 题意:对于动态计分的 Codeforces Round ,已知每题的 score 是根据 Round ...
- codeforces 807 C. Success Rate(二分)
题目链接:http://codeforces.com/contest/807/problem/C 题意:记 AC 率为当前 AC 提交的数量 x / 总提交量 y .已知最喜欢的 AC 率为 p/q ...
随机推荐
- 互评Alpha版本 - Hello World团队项目空天猎
在测评该项目时,我找到了Hello World!团队的git,并下载了相关文件以及阅读了程序运行说明. 如图所示,我下载了一个名为 SkyHunter1.0.rar 的压缩文件包,文件包内容如下: 根 ...
- 20162328蔡文琛 week06 大二
20162328 2017-2018-1 <程序设计与数据结构>第6周学习总结 教材学习内容总结 队列元素按FIFO的方式处理----最先进入的元素最先离开. 队列是保存重复编码k值得一种 ...
- 一个整数N中的1的个数
设计思想: 通过大量数据分解找规律 abcd 从d开始若d=0则count(1的个数)=左边的abc *d的位值(1.10.100..) 若等欲1则count=左边的abc*d的位值(1.10.100 ...
- yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。
CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql.com ...
- 获取emacs安装的elpa包名称
| grep "./" | sed 's/\.\///g' | sed 's/-[0-9].*$//' | sort -u
- 软工网络15团队作业4——Alpha阶段敏捷冲刺-5
一.当天站立式会议照片: 二.项目进展 昨天已完成的工作: 日期等细致信息的处理,对添加账单日期化. 明天计划完成的工作: 完成对账单的编辑,删除等操作,以及开始服务器的编写工作 工作中遇到的困难: ...
- selenium Object Page 设计模式理解及实现!
Page Object模式是Selenium中的一种测试设计模式,主要是将每一个页面设计为一个Class,其中包含页面中需要测试的元素(按钮,输入框,标题 等),这样在Selenium测试页面中可以通 ...
- selenium webdriver XPath的定位方法练习 !
html 代码: <html> <body> <div id="div1"> <input name="divl1input& ...
- appium手机操作
1.按键操作 pressKeyCode(key, metastate) key为按键事件,metastate为辅助功能键 举例: pressKeyCode(AndroidKeyCode.HOME) ...
- Fdisk 分区详解
Fdisk 分区详解 来源 http://blog.itpub.net/20674423/viewspace-722812/ 1. 通过Fdisk查看系统分区详细信息: Fdi ...