Plane of Tanks: Pro

                                                          Plane of Tanks: Pro

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.

Examples
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
Note

In the first example the best result, obtained by artem is not worse than the result that 25% of players have (his own result), so he belongs to category "noob". vasya and kolya have best results not worse than the results that 75% players have (both of them and artem), so they belong to category "random". igor has best result not worse than the result that 100% of players have (all other players and himself), so he belongs to category "pro".

In the second example both players have the same amount of points, so they have results not worse than 100% players have, so they belong to category "pro".


题目的意思就是给出一些人的得分,要求你按照上面那个给他们给好层次,pro random,noob之类的,然后输出,输出的顺序可以随意,但是这东西用map会挺方便的,所以用map就会和例子输出一样了。当然,如果一个人的成绩有好几个,取最大那个。

这题目其实弄的人很晕的,因为什么not worse than,不坏与,better,比什么什么好,搞得我头都转晕了,但是你千万不要学题目那样去分层次,看起来好像很条理清晰,实际上按照题目那样写判断条件是要用到浮点数的,而浮点数这东西,真是很靠脸的,就算是final上的选手,都不会优先选择要用浮点数的计算几何的题目。所以我们可以换个思维,逆向一下,我们从高向低处走,如果成绩比我好的少于等于1%,那就是pro,如果成绩比我好的少于等于10%,那就是hardcore,以此类推,用if    else if把这些判断条件连接起来就行了。

代码如下:

#include<cstdio>
#include<map>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	int point,n,mark[1005]={0},num,t,i,sum;
	char s[15];
	map<string,int>m;
	map<string,int>::iterator iter;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s%d",s,&point);
		if(m.find(s)==m.end())
		{
			m[s]=point;
			mark[point]++;
		}
		else if(point>m[s])
		{
			mark[m[s]]--;
			mark[point]++;
			m[s]=point;
		}
	}
	num=m.size();
	printf("%d\n",num); 
	for(iter=m.begin();iter!=m.end();iter++)
	{
		cout<<iter->first<<" ";
		t=mark[iter->second];
		for(i=iter->second+1,sum=0;i<=1000;i++)
			sum+=mark[i];
		if(sum*1.0<=0.01*num)
		{
			puts("pro");
		}
		else if(sum*1.0<=0.10*num)
		{
			puts("hardcore");
		}
		else if(sum*1.0<=0.20*num)
		{
			puts("average");
		}
		else if(sum*1.0<=0.50*num)
		{
			puts("random");
		}
		else
		{
			puts("noob");
		}
	}
	return 0;
}

我也试过按照题目那样打(当然你要保证你自己不会晕)然后就是这个浮点数的问题,在我电脑上是对的答案,在CF上判定输出却是另外一个结果,这就是浮点数的问题了,不知道CF上的浮点数取等于这些是怎么判断的,反正一直通用的eps 1e-7这个误差依然是过不了这题的,十分神奇

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值