ZOJ3770-Ranking System

来源:互联网 发布:linux oracle清空日志 编辑:程序博客网 时间:2024/06/10 07:38

Ranking System

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Few weeks ago, a famous software company has upgraded its instant messaging software. A ranking system was released for user groups. Each member of a group has a level placed near his nickname. The level shows the degree of activity of a member in the group.

Each member has a score based his behaviors in the group. The level is determined by this method:

LevelPercentageThe number of members in this levelLV1/All members whose score is zeroLV2/All members who can not reach level 3 or higher but has a positive scoreLV330%⌊(The number of members with a positive score) * 30%⌋LV420%⌊(The number of members with a positive score) * 20%⌋LV57%⌊(The number of members with a positive score) * 7%⌋LV63%⌊(The number of members with a positive score) * 3%⌋
  • x⌋ is the maximum integer which is less than or equal to x.
  • The member with the higher score will get the higher level. If two members have the same score, the earlier one who joined the group will get the higher level. If there is still a tie, the user with smaller ID will get the higher level.

Please write a program to calculate the level for each member in a group.

Input

There are multiple test cases. The first line of input is an integer T indicating the number of test cases. For each test case:

The first line contains an integer N (1 <= N <= 2000) indicating the number of members in a group.

The next N lines, each line contains three parts (separated by a space):

  1. The ID of the i-th member Ai (0 <= Ai <= 1000000000). The ID of each member is unique.
  2. The date of the i-th member joined the group, in the format of YYYY/MM/DD. The date will be in the range of [1900/01/01, 2014/04/06].
  3. The score Si (0 <= Si <= 9999) of the i-th member.

Output

For each test case, output N lines. Each line contains a string represents the level of the i-th member.

Sample Input

15123456 2011/03/11 308123457 2011/03/12 308333333 2012/03/18 4555555 2014/02/11 0278999 2011/03/18 308

Sample Output

LV3LV2LV2LV1LV2

Author: DAI, Longao
Source: The 14th Zhejiang University Programming Contest


题意:有N个人,给出一个人的信息:id,注册时间,积分,然后根据积分大小对这些人进行排序,如果积分相同按注册时间排序,早的排名靠前,如果注册时间也相同,那么根据id进行排序。然后按照排名分别给出其VIP等级,每个VIP等级是根据总人数的百分比来的,然后按输入顺序输出各个人的VIP等级


#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <cmath>#include <map>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>using namespace std;struct node{    int a,id;    int m,d,n;    int sorce;    string s;}x[2005];bool cmp(node x,node y){    if(x.sorce!=y.sorce) return x.sorce<y.sorce;    else if(x.n!=y.n) return x.n>y.n;    else if(x.m!=y.m) return x.m>y.m;    else if(x.d!=y.d) return x.d>y.d;    else return x.a>y.a;}bool cmp1(node x,node y){    return x.id<y.id;}int main(){    int t;    int n;    scanf("%d",&t);    while(t--)    {        scanf("%d",&n);        int sum1=0;        for(int i=1;i<=n;i++)        {            scanf("%d %d/%d/%d %d",&x[i].a,&x[i].n,&x[i].m,&x[i].d,&x[i].sorce);            x[i].id=i;            if(x[i].sorce==0) sum1++;        }        sort(x+1,x+1+n,cmp);        int sum3=(n-sum1)*0.3,sum4=(n-sum1)*0.2,sum5=(n-sum1)*0.07,sum6=(n-sum1)*0.03;        int sum2=n-sum1-sum3-sum4-sum5-sum6;        for(int i=1;i<=n;i++)        {            if(x[i].sorce==0) {x[i].s="LV1";continue;}            if(sum2) sum2--,x[i].s="LV2";            else if(sum3) sum3--,x[i].s="LV3";            else if(sum4) sum4--,x[i].s="LV4";            else if(sum5) sum5--,x[i].s="LV5";            else if(sum6) sum6--,x[i].s="LV6";        }        sort(x+1,x+1+n,cmp1);        for(int i=1;i<=n;i++) cout<<x[i].s<<endl;    }    return 0;}

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 鸡下的蛋壳是软怎么办 幼升小错过了现场审核怎么办 老人户口迁移到北京医保怎么办 过山洞经常堵耳朵怎么办 门有了一个洞该怎么办 公司要求补税没钱补怎么办 公司补税补不起了怎么办 脚被石头砸肿了怎么办 砸到脚背肿了怎么办 小猫吃完饭抓地怎么办 耳机链接处断了怎么办 表链从表盘断了怎么办 龟头和皮分开了怎么办 微信买票被骗了怎么办 撞车了我的全责怎么办 蒙田包包里面不耐脏怎么办? 摩托车转向灯不会打怎么办 浓硫酸弄到脸上怎么办 钥匙被锁在家里怎么办 有奶宝宝吸不出来怎么办 奶涨宝宝吸不出来怎么办 高铁票未取误点怎么办 飞猪上12306占座失败怎么办? 新生儿肚脐还没有脱落发炎怎么办 蹲坑被纸巾堵了怎么办 老公有外遇老婆不想离婚怎么办 结婚十年妻子出轨该怎么办 初生儿眼睛多眼屎怎么办 被丝袜脚摩擦过瘾了怎么办 老公在卧室装摄像头怎么办 听了鬼故事害怕怎么办 看完鬼片害怕睡不着怎么办 晚上看了鬼片怎么办 说话不经过大脑考虑怎么办 我太受欢迎了怎么办动漫结局 狗胃不好总呕吐怎么办 比格犬晚上叫怎么办 玻尿酸隆鼻变宽了怎么办 打玻尿酸鼻子变宽怎么办 鼻炎的人感冒了怎么办 小孩上幼儿园反复感冒怎么办