Codeforce Round #115 Plane of Tanks: Pro

B. Plane of Tanks: Pro

2000ms
2000ms
262144KB
64-bit integer IO format: %I64d Java class name: (Any)
Font Size:

Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several categories depending on their results.

A player is given a non-negative integer number of points in each round of the Plane of Tanks. Vasya wrote results for each round of the last year. He has n records in total.

In order to determine a player's category consider the best result obtained by the player and the best results of other players. The player belongs to category:

  • "noob" — if more than 50% of players have better results;
  • "random" — if his result is not worse than the result that 50% of players have, but more than 20% of players have better results;
  • "average" — if his result is not worse than the result that 80% of players have, but more than 10% of players have better results;
  • "hardcore" — if his result is not worse than the result that 90% of players have, but more than 1% of players have better results;
  • "pro" — if his result is not worse than the result that 99% of players have.

When the percentage is calculated the player himself is taken into account. That means that if two players played the game and the first one gained 100 points and the second one 1000 points, then the first player's result is not worse than the result that 50% of players have, and the second one is not worse than the result that 100% of players have.

Vasya gave you the last year Plane of Tanks results. Help Vasya determine each player's category.

Input

The first line contains the only integer number n (1 ≤ n ≤ 1000) — a number of records with the players' results.

Each of the next n lines contains a player's name and the amount of points, obtained by the player for the round, separated with a space. The name contains not less than 1 and no more than 10 characters. The name consists of lowercase Latin letters only. It is guaranteed that any two different players have different names. The amount of points, obtained by the player for the round, is a non-negative integer number and does not exceed 1000.

Output

Print on the first line the number m — the number of players, who participated in one round at least.

Each one of the next m lines should contain a player name and a category he belongs to, separated with space. Category can be one of the following: "noob", "random", "average", "hardcore" or "pro" (without quotes). The name of each player should be printed only once. Player names with respective categories can be printed in an arbitrary order.

Sample Input

Input
5
vasya 100
vasya 200
artem 100
kolya 200
igor 250
Output
4
artem noob
igor pro
kolya random
vasya random
Input
3
vasya 200
kolya 1000
vasya 1000
Output
2
kolya pro
vasya pro

个人第一道用map写的题目..........再一次感慨STL的厉害........贴了刚写完的代码,没有进行优化...凑合着看吧

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
struct node
{
    int sco;
};

int main()
{
    int i,j,n,score,m;
    string s;
    while(cin >> n)
    {
        map<string,node> stu;
        map<string,string> pri;
        map<string,node> ::iterator it;
        map<string,node> ::iterator it2;
        map<string,string> ::iterator it3;
        m = 0;
        int sum1;
        for(i=1; i<=n; i++)
        {
            cin >> s >> score;
            if(stu[s].sco < score)
                stu[s].sco = score;
        }
        for(it = stu.begin(); it!=stu.end(); it++)
            m++;
        for(it = stu.begin(); it!=stu.end(); it++)
        {
            //cout << (*it).first << ' ' << (*it).second.sco << endl;
            sum1 = 0;
            for(it2 = stu.begin(); it2!=stu.end(); it2++)
            {
                if((*it).second.sco < (*it2).second.sco)
                    sum1++;
            }
            //cout << sum1 << endl;
            double t = sum1 *1.0/ m*1.0;
            //printf("%.4f\n",t);
            if(t > 0.5)
            {
                pri[(*it).first] = "noob";
            }
            if(t <=0.5 && t> 0.2)
            {
                pri[(*it).first] = "random";
            }
            if(t <=0.2 && t> 0.1 )
            {
                pri[(*it).first] = "average";
            }
            if(t <=0.1 && t > 0.01)
            {
                pri[(*it).first] = "hardcore";
            }
            if(t <= 0.01)
            {
                pri[(*it).first] = "pro";
            }
        }
        cout << m << endl;
        for(it3 = pri.begin(); it3 !=pri.end(); it3++)
        {
            cout << (*it3).first << ' ' << (*it3).second << endl;
        }
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值