ZOJ3770Ranking System 2017-04-14 12:42 52人阅读 评论(0) 收藏
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:
| 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%⌋ |
- ⌊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.
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
题目的意思是给出每个等级的定义,在根据定义输出每个人的等级
思路:先统计出几个0分的,在排序之后按比例划分
#include <iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include <cstring>
using namespace std;
#define LL long long struct node
{
int id,no,y,m,d,v,lv;
} p[100005]; bool cmp(node a,node b)
{
if(a.v!=b.v) return a.v>b.v;
if(a.y!=b.y) return a.y<b.y;
if(a.m!=b.m) return a.m<b.m;
if(a.d!=b.d) return a.d<b.d;
return a.no<b.no;
}
bool cmp2(node a,node b)
{
return a.id<b.id;
} int main()
{
int T,n;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
int tot=0;
for(int i=0; i<n; i++)
{
p[i].id=i;
scanf("%d %d/%d/%d %d",&p[i].no,&p[i].y,&p[i].m,&p[i].d,&p[i].v);
if(p[i].v==0) tot++,p[i].lv=1;
}
sort(p,p+n,cmp);
tot=n-tot;
int cnt=0;
for(int i=1; i<=tot*0.03; i++)
p[cnt++].lv=6;
for(int i=1; i<=tot*0.07; i++)
p[cnt++].lv=5;
for(int i=1; i<=tot*0.20; i++)
p[cnt++].lv=4;
for(int i=1; i<=tot*0.30; i++)
p[cnt++].lv=3;
while(p[cnt].v>0)
p[cnt++].lv=2;
sort(p,p+n,cmp2);
for(int i=0; i<n; i++)
printf("LV%d\n",p[i].lv);
}
return 0;
}
ZOJ3770Ranking System 2017-04-14 12:42 52人阅读 评论(0) 收藏的更多相关文章
- 单链表操作B 分类: 链表 2015-06-07 12:42 15人阅读 评论(0) 收藏
数据结构上机测试2-2:单链表操作B TimeLimit: 1000ms Memory limit: 65536K 题目描述 按照数据输入的相反顺序(逆位序)建立一个单链表,并将单链表中重复的元素删除 ...
- Log4j 2使用教程 分类: B1_JAVA 2014-07-01 12:26 314人阅读 评论(0) 收藏
转载自 Blog of 天外的星星: http://www.cnblogs.com/leo-lsw/p/log4j2tutorial.html Log4j 2的好处就不和大家说了,如果你搜了2,说明你 ...
- ios UIKit动力 分类: ios技术 2015-07-14 12:55 196人阅读 评论(0) 收藏
UIkit动力学是UIkit框架中模拟真实世界的一些特性. UIDynamicAnimator 主要有UIDynamicAnimator类,通过这个类中的不同行为来实现一些动态特性. 它一般有两种初始 ...
- hdu 1035 (usage of sentinel, proper utilization of switch and goto to make code neat) 分类: hdoj 2015-06-16 12:33 28人阅读 评论(0) 收藏
as Scott Meyers said in his book Effective STL, "My advice on choosing among the sorting algori ...
- hdu 1030 Delta-wave (C++, 0ms, explanatory comments.) 分类: hdoj 2015-06-15 12:21 45人阅读 评论(0) 收藏
problem description http://acm.hdu.edu.cn/showproblem.php?pid=1030 #include <cstdio> #include ...
- Http,Https(SSL)的Url绝对路径,相对路径解决方案Security Switch 4.2的配置和使用 分类: ASP.NET 2014-11-05 12:51 97人阅读 评论(0) 收藏
下载地址1:https://securityswitch.googlecode.com/files/SecuritySwitch%20v4.2.0.0%20-%20Binary.zip 下载地址2:h ...
- winfrom 操作 INI 文件 分类: WinForm 2014-07-22 12:49 156人阅读 评论(0) 收藏
<strong><span style="font-size:18px;">(1)INI文件的名称:FileConfig.ini</span>& ...
- 【solr专题之四】关于VelocityResponseWriter 分类: H4_SOLR/LUCENCE 2014-07-22 12:32 1639人阅读 评论(0) 收藏
一.关于Velocity的基本配置 在Solr中,可以以多种方式返回搜索结果,如单纯的文本回复(XML.JSON.CSV等),也可以返回velocity,js等格式.而VelocityResponse ...
- hdu 1051 (greedy algorithm, how a little modification turn 15ms to 0ms) 分类: hdoj 2015-06-18 12:54 29人阅读 评论(0) 收藏
the 2 version are essentially the same, except version 2 search from the larger end, which reduce th ...
随机推荐
- Makefile编写 二
变量 1. Makefile中变量和函数的展开(除规则命令行中的变量和函数以外),是在make读取makefile文件时进行的,包括“define”定义的变量. 2. 变量可以用来代表一个文件名列表. ...
- (转)如何实现CSS限制字数,超出部份显示点点点...
<div style="width:200px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis; border:1 ...
- 补充: istio安装
首先有一个概念: CRD - Custom Resource Definitions: CRDS文件: install/kubernetes/helm/istio/templates/crds.yml ...
- Pycharm上python和unittest两种姿势傻傻分不清楚
前言 经常有人在群里反馈,明明代码一样的啊,为什么别人的能出报告,我的出不了报告:为什么别人运行结果跟我的不一样啊... 这种问题先检查代码,确定是一样的,那就是运行姿势不对了,一旦导入unittes ...
- C#中使用DLL相关问题
一,C#调用 C/C++ 库函数 1,UNITY的C# VS工程常常打不开 属性页,右键工程无 [添加引用]项.原因是VS的自带工具[适用于UNITY的工具]导致的. 解决办法:VS-[工具]-[选项 ...
- 无法启动Tomcat, 端口被占用的问题
这个错误是说这几个端口已经有某个应用程序占用了,所以Tomcat就没法启动了. 出现这个问题的原因可能有以下几种: 情况一:点击运行的时候没有选中页面或Servlet窗口的标签 标签被选中时: 标 ...
- win10如和设置远程桌面
最近几天一直在搞远程桌面问题,电脑一直连不上远程,今天终于出来了. 前提前提 条件,要电脑允许Administrator用户,先把电脑切换到那个用户,然后进行下面操作. 1.在桌面,我的电脑图标,鼠 ...
- android应用程序monkey压力测试(模拟器或真机)
首先需要安装一个模拟器: 前置条件: 1.jdk环境配置 2.eclipse下载安装(直接解压即可) 3.网站上下载ADT: 由于国内禁止google的浏览,所以需要自己上网找资源,下面这个网站有比较 ...
- Ant+jmeter+jenkins搭建测试的持续集成
前提: Ant+jmeter 已经搭建完成并成功运行(参看ant+jmeter自动化性能测试) Jenkins在本地已经安装可运行(参看上一篇) 1.下载Jenkins安装 2.浏览器输入地址http ...
- 如何快速简单粗暴地理解Python中的if __name__ == '__main__'
1. 摘要 通俗的理解__name__ == '__main__':假如你叫小明.py,在朋友眼中,你是小明(__name__ == '小明'):在你自己眼中,你是你自己(__name__ == '_ ...