Ranking System
来源:互联网 发布:马思纯演技 知乎 编辑:程序博客网 时间:2024/06/05 08:24
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.
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.
#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<iostream>using namespace std;struct Node{ int num; int id; string year; int score; string lv;}node[2100];int n;bool cmp1(Node a,Node b){ if(a.score != b.score) return a.score>b.score; else if(a.year != b.year) return a.year < b.year; else if(a.id != b.id) return a.id<b.id;}bool cmp2(Node a,Node b){ return a.num < b.num;}int main(){ int t; int i; int cnt,zero; int lv1,lv2,lv3,lv4,lv5,lv6; scanf("%d",&t); while(t--){ scanf("%d",&n); cnt = 0; zero = 0; for(i = 0;i<n;i++){ node[i].num = i; cin>>node[i].id>>node[i].year>>node[i].score; if(node[i].score>0) cnt++; if(node[i].score==0) zero ++; } lv1 = lv2 = lv3 = lv4 = lv5 = lv6 = 0; lv1 = zero; lv3 = cnt * 0.3; lv4 = cnt * 0.2; lv5 = cnt * 0.07; lv6 = cnt * 0.03; lv2 = n - lv1-lv3-lv4-lv5-lv6; //printf("%d %d %d %d %d %d\n",lv1,lv2,lv3,lv4,lv5,lv6); sort(node,node+n,cmp1); for(i = 0;i<n;i++){ if(lv6!=0){ node[i].lv = "LV6"; lv6--; continue; } else if(lv5!=0) { node[i].lv = "LV5"; lv5 --; continue; } else if(lv4!=0){ node[i].lv = "LV4"; lv4--; continue; } else if(lv3 !=0) { node[i].lv = "LV3"; lv3--; continue; } else if(lv2!=0){ node[i].lv = "LV2"; lv2--; continue; } else if(lv1!=0){ node[i].lv = "LV1"; lv1--; continue; } } sort(node,node+n,cmp2); for(i = 0;i<n;i++) cout<<node[i].lv<<endl; } return 0;}
//先求出各种等级的人数,然后通过两次排序,即可求得答案。
- Ranking System
- Ranking System
- D、Ranking System
- ZOJ3770:Ranking System
- ZOJ 3770 Ranking System
- ZOJ 3770 Ranking System
- ZOJ 3770 Ranking System
- ZOJ3770-Ranking System
- ZOJ 3770 Ranking System 模拟
- ZOJ 3770 Ranking System(模拟)
- ZOJ-3770(Ranking System)
- ZOJ 3770 Ranking System(排序)
- Ranking
- HLG 2120Ranking System【树状数组+map+二分】
- 第14届浙江大学程序设计竞赛 D. Ranking System(ZOJ 3770)
- ZOJ 3770 : Ranking System (第14届浙江大学程序设计竞赛 D) - 结构体排序,vector
- RANKING ACTIONS
- PAT Ranking
- QT——QSignalMapper
- XML(1)——shema约束之命名空间
- crashlytics版本区分
- 使用C#开发百度空间验证码自动填写的工具
- 安卓学习笔记(一)
- Ranking System
- HTTP协议网络传输
- JS使用正则表达式操作字符串
- 保护android进程相关技术点
- PHP获取访客真实IP 即使加了代理服务器.
- 很多项目经理,计划做得很漂亮,却总是计划赶不上变化
- 使用SOAP的XML消息传递
- source insight 无法对齐
- 12.3摩托车继承自行车和机动车