ZOJ 3770 Ranking System(排序)

来源:互联网 发布:好听淘宝名字大全 编辑:程序博客网 时间:2024/06/17 08:58

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

题解:

很水的一道排序练习题,注意下百分百乘的数是分数为正数的数的数目

代码:

#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<math.h>#include<vector>#include<map>#include<set>#include<stdlib.h>#include<cmath>#include<string>#include<algorithm>#include<iostream>#include<stdio.h>using namespace std;#define ll long longstruct node{    int id;    int y,m,d;    int s;    int r;}a[2005];int b[2005];int cmp(node a,node b){    if(a.s!=b.s)    {        return a.s>b.s;    }    if(a.y!=b.y||a.m!=b.m||a.d!=b.d)    {        if(a.y!=b.y)        {            return a.y<b.y;        }        else        {            if(a.m!=b.m)            {                return a.m<b.m;            }            else            {                return a.d<b.d;            }        }    }    return a.id<b.id;}int main(){    int i,j,n,test,ans;    while(scanf("%d",&test)!=EOF)    {        while(test--)        {            scanf("%d",&n);            ans=0;            for(i=1;i<=n;i++)            {                scanf("%d%d/%d/%d%d",&a[i].id,&a[i].y,&a[i].m,&a[i].d,&a[i].s);                a[i].r=i;                if(a[i].s>0)                    ans++;            }            sort(a+1,a+n+1,cmp);            int a6=ans*0.03,a5=ans*0.07,a4=ans*0.2,a3=ans*0.3;            for(i=1;i<=n;i++)            {                if(a6)                {                    b[a[i].r]=6;                    a6--;                }                else if(a5)                {                    b[a[i].r]=5;                    a5--;                }                else if(a4)                {                    b[a[i].r]=4;                    a4--;                }                else if(a3)                {                    b[a[i].r]=3;                    a3--;                }                else                {                    if(a[i].s>0)                        b[a[i].r]=2;                    else                        b[a[i].r]=1;                }            }            for(i=1;i<=n;i++)            {                printf("LV%d\n",b[i]);            }        }    }    return 0;}



阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 微信不能语音了怎么办 微信不能发语音怎么办? 苹果6话筒声音小怎么办 微信视频杂音大怎么办 微信语音有杂音怎么办 苹果手机音频坏了怎么办 苹果手机送话器坏了怎么办 苹果7听筒声音大怎么办 苹果6听筒声音小怎么办 苹果7电话声音小怎么办 苹果7plus声音小怎么办 苹果7通话音量小怎么办 苹果4s声音小怎么办 苹果4s没有声音怎么办 手机送话筒坏了怎么办 安卓手机声音小怎么办 微信说话没声音怎么办 小米6话筒声音小怎么办 小米4通话声音小怎么办 电容麦有电流声怎么办 苹果6说话声音小怎么办 耳机漏音怎么办小招 win8耳机孔坏了怎么办 魔音耳机开胶了怎么办 苹果6plus声音小怎么办 苹果6铃声不响怎么办 苹果6静音键失灵怎么办 苹果7手机音量小怎么办 苹果4s声音太小怎么办 苹果6声音变小了怎么办 6s扬声器声音小怎么办 苹果手机6听筒声音小怎么办 苹果7听筒声音小怎么办 苹果6音量小了怎么办 苹果手机8声音小怎么办 苹果6plus音量小怎么办 苹果8通话声音小怎么办 苹果7听筒坏了怎么办 苹果6s听筒坏了怎么办 苹果6听筒坏了怎么办 苹果7听筒进油了怎么办