Codeforces Round #412 A Is it rated ?
2 seconds
256 megabytes
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.
题目大意: 首先输入一个n表示参赛人数,然后给出n个人参赛前的分数和参赛后
的分数,要求判断比赛完之后是否rate;
解题思路:首先判断赛前和赛后的分数是否相同,不同的话一定rate,
否则判断是否按降序排列,是maybe否unrate。
AC代码:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm> using namespace std; struct Rating
{
int s;
int e;
}p[]; int main ()
{
int n,i;
int sum,s,j,flag;
while (~scanf("%d",&n))
{
flag = ;
for (i = ; i < n; i ++)
scanf("%d %d",&p[i].s,&p[i].e);
for (i = ; i < n; i ++) // 首先判断分数是否有变化
if (p[i].s != p[i].e)
{
flag = ; break;
}
if (flag)
{
printf("rated\n"); continue;
}
j = s = ;
for (i = ; i < n; i ++) // 然后判断是否是降序
{
if (p[i].s <= p[i-].s)
j ++;
}
if (j == n)
printf("maybe\n");
else
printf("unrated\n");
}
return ;
}
Codeforces Round #412 A Is it rated ?的更多相关文章
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring
地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...
- Codeforces Round#412 Div.2
A. Is it rated? 题面 Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codefo ...
- Codeforces Round #412 Div. 2 第一场翻水水
大半夜呆在机房做题,我只感觉智商严重下降,今天我脑子可能不太正常 A. Is it rated? time limit per test 2 seconds memory limit per test ...
- Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A Is it rated?
地址:http://codeforces.com/contest/807/problem/C 题目: C. Success Rate time limit per test 2 seconds mem ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心
E. Prairie Partition It can be shown that any positive integer x can be uniquely represented as x = ...
- Codeforces Round #412 B. T-Shirt Hunt
B. T-Shirt Hunt time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
随机推荐
- LTE
LTE (telecommunication), Long Term Evolution, a telephone and mobile broadband communication standar ...
- django 迁移工程数据库无法创建的问题
1.今天我遇到一个问题在此做笔记记下来 2.我晚上一般是在家练习的,白天会拷贝工程到公司用 3.因为我在家里创建过一次数据库了,通过命令创建,但是无论我怎么修改models都无法创建表,最后只能通过新 ...
- my.等级限制
1.20190405 “春之恋曲 4月5日双平台新服开服公告”,20190426 上去新建了一个号 发现等级限制是 66级(2天后开启新等级) 20190412 “胭脂雪 4月12日双平台新服开服 ...
- css :before 内容左边 分割线(四)
商品 左边分割线,使用css伪类实现,before or after <style> *{ margin:; padding:; } .clearfix { *zoom:; } .cle ...
- Jmeter调试脚本之断言
前言: jmeter中有个元件叫做断言(Assertion),它的作用和loadrunner中的检查点类似: 用于检查测试中得到的响应数据等是否符合预期,用以保证性能测试过程中的数据交互与预期一致. ...
- 009-MailUtils工具类模板
版本一:JavaMail的一个工具类 package ${enclosing_package}; import java.security.GeneralSecurityException; impo ...
- 关于JS闭包
今天在敲代码的时候,发现很多JQ插件在写闭包的时候都会用到下面的写法: (function ($) { ... })(jQuery); 一时的好奇心驱使,我研究起了这一写法来.大家都知道,在 $ 没有 ...
- 1.7 js基础,字符串、数组小结
一.arguments 实参参数的数组 实参[实际的值],形参[形式上的参数] 当参数个数不固定的时候使用. 示例: script> var g ...
- 通过管道传输快速将MySQL的数据导入Redis
通过管道传输pipe将MySQL数据批量导入Redis 自Redis 2.6以上版本起,Redis支持快速大批量导入数据,即官网的Redis Mass Insertion,即Pipe传输, ...
- js中的特殊符号含义
一. !! js中的!! var o ={flag:4}; var test = !!o.flag; console.log(test); // true 二.~~,<< (~~(Mat ...