ZOJ3770:Ranking System

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 level
LV1/All members whose score is zero
LV2/All members who can not reach level 3 or higher but has a positive score
LV330%⌊(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
1
5
123456 2011/03/11 308
123457 2011/03/12 308
333333 2012/03/18 4
555555 2014/02/11 0
278999 2011/03/18 308
Sample Output
LV3
LV2
LV2
LV1
LV2
 
只要知道每个等级有几个人即可
 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;

struct node
{
    int id,y,m,d,val;
    int lv,no;
} a[2005];

int cmp(node a,node b)
{
    if(a.val!=b.val)
        return a.val>b.val;
    if(a.y!=b.y)
        return a.y<b.y;
    if(a.m!=b.m)
        return a.m<b.y;
    if(a.d!=b.d)
        return a.d<b.d;
    return a.id<b.id;
}

int cmp2(node a,node b)
{
    return a.no<b.no;
}

int main()
{
    int t,n,i;
    int l3,l4,l5,l6;
    cin >> t;
    while(t--)
    {
        cin >> n;
        int cnt = 0;
        for(i = 0; i<n; i++)
        {
            scanf("%d %d/%d/%d %d",&a[i].id,&a[i].y,&a[i].m,&a[i].d,&a[i].val);
            a[i].no = i;
            if(a[i].val>0)
                cnt++;
        }
        l3 = cnt*0.3;
        l4 = cnt*0.2;
        l5 = cnt*0.07;
        l6 = cnt*0.03;
        sort(a,a+n,cmp);
        for(i = 0; i<n; i++)
        {
            if(!a[i].val)
                a[i].lv = 1;
           else if(l6)
            {
                a[i].lv = 6;
                l6--;
            }
            else if(l5)
            {
                a[i].lv = 5;
                l5--;
            }
            else if(l4)
            {
                a[i].lv = 4;
                l4--;
            }
            else if(l3)
            {
                a[i].lv = 3;
                l3--;
            }
            else
                a[i].lv = 2;
        }
        sort(a,a+n,cmp2);
        for(i = 0; i<n; i++)
            printf("LV%d\n",a[i].lv);
    }

    return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值