A. Is it rated?
time limit per test             

2 seconds

memory limit per test       

256 megabytes

input      

standard input

output

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.

Input

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.

Output

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".

Examples
input
6
3060 3060
2194 2194
2876 2903
2624 2624
3007 2991
2884 2884
output
rated
input
4
1500 1500
1300 1300
1200 1200
1400 1400
output
unrated
input
5
3123 3123
2777 2777
2246 2246
2246 2246
1699 1699
output
maybe
Note

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?的更多相关文章

  1. 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 ...

  2. 【codeforces 807A】Is it rated?

    [题目链接]:http://codeforces.com/contest/807/problem/A [题意] 给你n个人在一场CF前后的rating值; 问你这场比赛是不是计分的 [题解] 如果有一 ...

  3. 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 ...

  4. 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 ...

  5. Codeforces 807 C. Success Rate

    http://codeforces.com/problemset/problem/807/C C. Success Rate time limit per test 2 seconds memory ...

  6. Codeforces 807 B T-Shirt Hunt

    B. T-Shirt Hunt http://codeforces.com/problemset/problem/807/B time limit per test 2 seconds memory ...

  7. codeforces 807 E. Prairie Partition(贪心+思维)

    题目链接:http://codeforces.com/contest/807/problem/E 题意:已知每个数都能用x=1 + 2 + 4 + ... + 2k - 1 + r (k ≥ 0, 0 ...

  8. codeforces 807 D. Dynamic Problem Scoring(贪心+思维)

    题目链接:http://codeforces.com/contest/807/problem/D 题意:对于动态计分的 Codeforces Round ,已知每题的 score 是根据 Round ...

  9. codeforces 807 C. Success Rate(二分)

    题目链接:http://codeforces.com/contest/807/problem/C 题意:记 AC 率为当前 AC 提交的数量 x / 总提交量 y .已知最喜欢的 AC 率为 p/q ...

随机推荐

  1. Scrum立会报告+燃尽图(Beta阶段第六次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2388 项目地址:https://coding.net/u/wuyy694 ...

  2. PSP Daily——团队项目Alpha发布

    视频展示:优酷视频链接.文案如下 PSP Daily软件NABCD分析: 1) N (Need 需求) PSP Daily 解决了用户(软件工程课上学生)记录例行报告.写每周PSP表格和统计的需求.潜 ...

  3. 《C》数据类型

  4. Spring学习(六)—— Spring注解(二)

    核心原理 1.       用户发送请求给服务器.url:user.do 2.       服务器收到请求.发现Dispatchservlet可以处理.于是调用DispatchServlet. 3.  ...

  5. PAT 甲级 1063 Set Similarity

    https://pintia.cn/problem-sets/994805342720868352/problems/994805409175420928 Given two sets of inte ...

  6. Bootstrap-tagsinput标系统使用心得

    最近工作中由于需求使用到了Bootstrap-tagsinput标系统,我的需求是: 1)能够从后台数据库获取标签信息展示到前端页面: 2)能够实现输入标签添加到后台,并ajax刷新页面: 3)能够实 ...

  7. Python @retry装饰器的使用与实现案例(requests请求失败并重复请求)

    在爬虫代码的编写中,requests请求网页的时候常常请求失败或错误,一般的操作是各种判断状态和超时,需要多次重试请求,这种情况下,如果想优雅的实现功能,可以学习下retrying包下的retry装饰 ...

  8. js中如何获取页面的Url,域名和端口号

    有时候通过获取上个页面的Url来做一个跳转,获取域名防止非正常访问 获取上一个页面的一个URL,这个URL一般做一个页面的跳转 window.location.href <script>w ...

  9. 转载-C++ vector 用法

    转自:http://www.cnblogs.com/wang7/archive/2012/04/27/2474138.html 在c++中,vector是一个十分有用的容器,下面对这个容器做一下总结. ...

  10. hdu6415 Rikka with Nash Equilibrium (DP)

    题目链接 Problem Description Nash Equilibrium is an important concept in game theory. Rikka and Yuta are ...