ZOJ 3770 Ranking System

来源:互联网 发布:seo黑帽工具有哪些 编辑:程序博客网 时间:2024/06/07 09:53
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

本题先给出T组样例,每组样例首先给出N,代表人数,接下来每行给出一个人的信息:id,注册时间,积分
然后根据积分大小对这些人进行排序,如果积分相同按注册时间排序,早的排名靠前,如果注册时间也相同,那么根据id进行排序.
然后按照排名分别给出其VIP等级,然后按输入顺序输出各个人的VIP等级.
#include <iostream>#include<string>#include<cstdio>#include<vector>#include<cstring>#include<algorithm>#include<map>using namespace std;struct node{    int i;    int id;    int yy,mm,dd;    int score;    string s;} p[2005];vector<node> v;bool cmp(node a,node b){    if(a.score!=b.score) return a.score<b.score;    if(a.yy!=b.yy) return a.yy>b.yy;    if(a.mm!=b.mm) return a.mm>b.mm;    if(a.dd!=b.dd) return a.dd>b.dd;    return a.id>b.id;}bool cmp1(node a,node b){    return a.i<b.i;}int main(){    int t;    cin>>t;    while(t--)    {        v.clear();        int n;        cin>>n;        int cnt=0;        int cnt1=0;        for(int i=0; i<n; i++)        {            scanf("%d %d/%d/%d %d",&p[i].id,&p[i].yy,&p[i].mm,&p[i].dd,&p[i].score);            p[i].i=i;            if(p[i].score==0) cnt1++;        }        sort(p,p+n,cmp);        int num=n-cnt1;        int ra[7];        ra[0]=0;        ra[6]=num*3/100;        ra[5]=num*7/100;        ra[4]=num*20/100;        ra[3]=num*30/100;        for(int i=n-1; i>=0; i--)        {            if(p[i].score==0) p[i].s="LV1";            else            {                if(ra[6]>0)                {                    p[i].s="LV6";                    ra[6]--;                    continue;                }                if(ra[5]>0)                {                    p[i].s="LV5";                    ra[5]--;                    continue;                }                if(ra[4]>0)                {                    p[i].s="LV4";                    ra[4]--;                    continue;                }                if(ra[3]>0)                {                    p[i].s="LV3";                    ra[3]--;                    continue;                }                p[i].s="LV2";            }        }        sort(p,p+n,cmp1);        for(int i=0; i<n; i++)            cout<<p[i].s<<endl;    }    return 0;}


0 0