zoukankan      html  css  js  c++  java
  • Codeforces Round #412 A Is it rated ?

    A. Is it rated?
    time limit per test 
    2 seconds 
    memory limit per test 
    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.

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

    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.

    题目大意: 首先输入一个n表示参赛人数,然后给出n个人参赛前的分数和参赛后

          的分数,要求判断比赛完之后是否rate;

    解题思路:首先判断赛前和赛后的分数是否相同,不同的话一定rate,

         否则判断是否按降序排列,是maybe否unrate。

    AC代码:

     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <math.h>
     4 #include <stdlib.h>
     5 #include <algorithm>
     6 
     7 using namespace std;
     8 
     9 struct Rating
    10 {
    11     int s;
    12     int e;
    13 }p[1010];
    14 
    15 int main ()
    16 {
    17     int n,i;
    18     int sum,s,j,flag;
    19     while (~scanf("%d",&n))
    20     {
    21         flag = 0;
    22         for (i = 0; i < n; i ++)
    23             scanf("%d %d",&p[i].s,&p[i].e);
    24         for (i = 0; i < n; i ++)   // 首先判断分数是否有变化
    25             if (p[i].s != p[i].e)
    26             {
    27                 flag = 1; break;
    28             }
    29         if (flag)
    30         {
    31             printf("rated
    "); continue;
    32         }
    33         j = s = 1;
    34         for (i = 1; i < n; i ++)  // 然后判断是否是降序
    35         {
    36             if (p[i].s <= p[i-1].s)
    37                 j ++;
    38         }
    39         if (j == n)
    40             printf("maybe
    ");
    41         else
    42             printf("unrated
    ");
    43     }
    44     return 0;
    45 }
  • 相关阅读:
    html_py
    PHP-FPM详解
    nginx 虚拟主机配置
    正确配置Nginx+PHP
    centos7安装Nginx
    如何让浏览器关闭后session失效
    微擎中消息响应回复 代码流程
    在vue组件库中不能使用v-for
    微信分享前面
    php接受axios数据
  • 原文地址:https://www.cnblogs.com/yoke/p/6828475.html
Copyright © 2011-2022 走看看