ZOJ3770
2014-04-07 13:08
141 查看
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:
⌊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.
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):
The ID of the i-th member Ai (0 <= Ai <= 1000000000). The ID of each member is unique.
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].
The score Si (0 <= Si <= 9999) of the i-th member.
[/code]
Each member has a score based his behaviors in the group. The level is determined by this method:
Level | Percentage | The 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 |
LV3 | 30% | ⌊(The number of members with a positive score) * 30%⌋ |
LV4 | 20% | ⌊(The number of members with a positive score) * 20%⌋ |
LV5 | 7% | ⌊(The number of members with a positive score) * 7%⌋ |
LV6 | 3% | ⌊(The number of members with a positive score) * 3%⌋ |
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):
The ID of the i-th member Ai (0 <= Ai <= 1000000000). The ID of each member is unique.
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].
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<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; struct nn { char A[50],date[20]; int sc,i; }pep[2005]; int cmp(struct nn a,struct nn b) { if(a.sc>b.sc)return a.sc>b.sc; else if(a.sc<b.sc) return a.sc>b.sc; else if(strcmp(a.date,b.date)>0&&a.sc==b.sc) return strcmp(a.date,b.date)<0; else if(strcmp(a.date,b.date)==0&&strcmp(a.A,b.A)>0&&a.sc==b.sc) return strcmp(a.A,b.A)<0; } int main() { int leveNum[8],ans,t,n,Leve[2005]; scanf("%d",&t); while(t--) { scanf("%d",&n); ans=0; leveNum[1]=0; for(int i=0;i<n;i++) { scanf("%s %s %d",pep[i].A,pep[i].date,&pep[i].sc); pep[i].i=i; if(pep[i].sc>0)ans++; } leveNum[3]=(int)(ans*0.3); leveNum[4]=(int)(ans*0.2); leveNum[5]=(int)(ans*0.07);leveNum[6]=(int)(ans*0.03); sort(pep,pep+n,cmp); int j=0; for(int i=6;i>2;i--) if(leveNum[i]) { for(;j<n&&leveNum[i];j++) { Leve[pep[j].i]=i;leveNum[i]--; } } for(;j<n;j++) { if(pep[j].sc)Leve[pep[j].i]=2; else Leve[pep[j].i]=1; } for(int i=0;i<n;i++) { printf("LV%d\n",Leve[i]); } } }
[/code]
相关文章推荐
- OGNL表达式struts2标签“%,#,$”
- 普适系统中的动态多限制的任务分解划分算法
- 数组作数据成员
- PE文件结构详解(五)延迟导入表
- PE文件结构详解(四)PE导入表
- PE文件结构详解(三)PE导出表
- unity3D游戏开发六之创建基本游戏场景三
- 从Java到C++——数组的用法
- android拨号器
- 【每日一C之十三】C 语言inline内联函数
- UVA Ananagrams
- hdu 1070 Milk (水题,贪心)
- [黑马程序员]集合--Map
- 范式
- yii --memcached缓存的配置
- java批量修改文件后缀名
- Decorator Pattern(装饰模式)
- Coursera 程序设计实习 / Practice on Programming 笔记(第一周)
- 在虚拟中开启Windows 8.1的Hyper-V平台
- 【Selenium1】第一个SeleniumWebdrive脚本