码迷,mamicode.com
首页 > 其他好文 > 详细

B - Plane of Tanks: Pro

时间:2014-11-01 13:09:05      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   color   os   ar   for   sp   

Description

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
#include<iostream>
#include<cstdio>
#include<map>
#include<string>
using namespace std;
int main()
{
    int i,j,k,n,x,sum,cnt;
    string str;
    map<string,int> score;
    map<string,string> cate;
//    scanf("%d",&n);
    cin>>n;
    while(n--)
    {
        cin>>str>>x;
        if(score[str]<x)
            score[str]=x;
    }
    map<string,int>::iterator it,it2;
    cnt=score.size();
    for(it=score.begin();it!=score.end();it++)
    {
        sum=0;
        for(it2=score.begin();it2!=score.end();it2++)
        {
            if(it->second<it2->second)
                sum++;
        }
        double p=sum*1.0/cnt;
        if(p>0.5)  
            cate[it->first]="noob";  
        else if(p>0.2&&p<=0.5)  
            cate[it->first]="random";  
        else if(p>0.1&&p<=0.2 )   
            cate[it->first]="average";   
        else if(p>0.01&&p<=0.1)  
            cate[it->first]="hardcore";  
        else 
            cate[it->first]="pro";  
    }
    cout<<cnt<<endl;//忘记输出 
    for(map<string,string>::iterator tt=cate.begin();tt!=cate.end();tt++)
    {
        cout<<tt->first<<" "<<tt->second<<endl;
    }
    return 0;
}

 

B - Plane of Tanks: Pro

标签:des   style   blog   io   color   os   ar   for   sp   

原文地址:http://www.cnblogs.com/767355675hutaishi/p/4066927.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!