HDU - 3040 - Happy Girls
先上题目:
Happy Girls
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1356 Accepted Submission(s): 233
Long1 and xinxin like it very much, they even use their cellphones to suppose the girl who they like most. This way is easy if you have enough money then you can make a contribution toward your lover.
But sometimes, it also causes the problem of injustice. Those who has a lot of money can support their lover in every second. So now, we make a rule to restrict them – every tel-number can just support once in one minute (i.e two messages should have difference bigger or equal 60s).
As an exerllent programer, your mission is to count every Happy girl’s result.
For every case:
The first line gives N, represents there are N happy gilrs numbered form 1 to N(N<=10)
Then many lines follows(no more than 50000), each line gives the time one sent his/her message, the cellphone number and the number he/she support. They are sepatated by space.
The last line an message “#end”.
Each line begin with the Happy girls’ number, then a colon, then a bunch of “*” follows, the number of the “*” are Happy girls’ votes.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX 50004
#define LL long long
using namespace std; typedef struct{
LL ti;
LL num;
int p;
}vote; vote v[MAX];
int tot;
int girl[]; typedef struct{
LL la;
LL num;
}user; user u[MAX];
int o; void check(int t){
if(u[o].num==v[t].num){
if(u[o].la>= && v[t].ti-u[o].la<){
u[o].la=v[t].ti;
return;
}
}else{
o++;
u[o].num=v[t].num;
}
u[o].la=v[t].ti;
girl[v[t].p]++;
} bool cmp(vote x,vote y){
if(x.num<y.num) return ;
else if(x.num==y.num && x.ti<y.ti) return ;
return ;
} int main()
{
int t,k,t_[];
char a[];
//freopen("data.txt","r",stdin);
while(scanf("%d",&t)!=EOF){
getchar();
tot=;
memset(girl,,sizeof(girl));
memset(u,-,sizeof(u));
o=;
while(scanf("%s",a),a[]!='#'){
sscanf(a,"%d:%d:%d",&t_[],&t_[],&t_[]);
k=;
for(int i=;i<;i++){
k=k*+t_[i];
}
v[tot].ti=k;
scanf("%I64d",&v[tot].num);
scanf("%d",&v[tot].p);
tot++;
}
sort(v,v+tot,cmp);
for(int i=;i<tot;i++){
check(i);
}
printf("The result is :\n");
for(int i=;i<=t;i++){
printf("%02d : ",i);
for(int j=;j<girl[i];j++) putchar('*');
printf("\n");
}
}
return ;
}
3040
HDU - 3040 - Happy Girls的更多相关文章
- 【HDU 6017】 Girls Love 233 (DP)
Girls Love 233 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- HDU——T 1068 Girls and Boys
http://acm.hdu.edu.cn/showproblem.php?pid=1068 Time Limit: 20000/10000 MS (Java/Others) Memory Li ...
- 【hdu 1068】Girls and Boys
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=1068 [Description] 有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人 ...
- HDU 3294 (Manacher) Girls' research
变形的求最大回文子串,要求输出两个端点. 我觉得把'b'定义为真正的'a'是件很无聊的事,因为这并不会影响到最大回文子串的长度和位置,只是在输出的时候设置了一些不必要的障碍. 另外要注意一下原字符串s ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- hdu图论题目分类
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...
- HDU图论题单
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...
- HDU2063 过山车(二分匹配)
过山车 HDU - 2063 RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做part ...
- hdu 2579 Dating with girls(2)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...
随机推荐
- bzoj1179 [Apio2009]Atm——缩环最长路
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1179 tarjan 缩环,然后求到有酒吧的点的最长路即可: 但一开始想缩环后用拓扑序求答案, ...
- c++ string 解析ip
比如输入是192.168.80.12-15,解析成192.168.80.12.192.168.80.13.192.168.80.14.192.168.80.15. #include <iostr ...
- Fisher 线性判别
Multiplying both sides of this result by wT and adding w0, and making use of y(x)=wTx+w0 and y(xΓ)= ...
- Hamming Distance(随机算法)
http://acm.hdu.edu.cn/showproblem.php?pid=4712 题意:计算任意两个十六进制的数异或后1的最少个数. 思路:用随机数随机产生两个数作为下标,记录这两个数异或 ...
- json用法
什么是JSON? JavaScript 对象表示法(JavaScript Object Notation). JSON是一种轻量级的数据交换格式,某个JSON格式的文件内部譬如可以长成这样: 1 2 ...
- HTML多媒体标记之字幕标记
在HTML中,可以向页面中插入字幕,水平或垂直滚动显示文字信息,字幕标记的格式如下: <marquee 属性="值"...>滚动的文字信息</marquee> ...
- 关于Vue.js去掉#号路由
正常启动后访问路由: 中间会自动加入一个#号 去掉#号: 在route文件夹下的index.js中加入mode: 'history', ①: ②: 关于mode说明: 默认值: ‘hash‘(浏览器) ...
- HTML <!DOCTYPE>标签
一般一个基本html页面的结构,如下代码所示: <html> <head> <title>我是基本的页面结构</title> </head> ...
- HBase的集群搭建(1、3、5节点都适用)
见 5 hbase-shell + hbase的java api
- 深入浅出java多态
所谓多态就是指程序中定义的引用变量所指向的具体类型和通过该引用变量发出的方法调用在编程时并不确定,而是在程序运行期间才确定,即一个引用变量倒底会指向哪个类的实例对象,该引用变量发出的方法调用到底是哪个 ...