先上题目:

Happy Girls

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1356    Accepted Submission(s): 233

Problem Description
These days, Hunan TV host the big concert – Happy Girls.
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.

 
Input
There are many cases. 
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”.

 
Output
In every case, you print “The result is : ”, then N line follows.
Each line begin with the Happy girls’ number, then a colon, then a bunch of “*” follows, the number of the “*” are Happy girls’ votes.
 
Sample Input
4
0:12:25 13854241556 1
0:15:52 15825422365 2
0:15:56 15825422365 3
0:18:55 13625415457 2
11:12:2 13954215455 4
5:41:55 13625415457 2
#end
 
Sample Output
The result is :
01 : *
02 : ***
03 :
04 : *
 
  题意:给出一系列手机号码,其发送信息的时间以及投票的对象,求最终每个被投票对象的得票数。这里有一个要求,就是对于同一个人的信息需要判断是不是在60秒以内连续发的,如果是,那当前这一次投票不计。这里可能有一点歧义,①60秒以内连续发多条短信,那是只以第一条短信为60秒的开始计时点还是每收到一条短信,都会以新的一条短信为计时的开始点。不过这里两种情况都会AC。
  做法就是先对每一个手机用户的投票情况进行排序,然后统计一遍就可以了。值得注意的是对于同一个用户连续两条短信的间距只要大于等于60秒就可以了。
  还有就是,这一题用C++交可能会WA,用G++交的话才会AC。
 
上代码:
 
 #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的更多相关文章

  1. 【HDU 6017】 Girls Love 233 (DP)

    Girls Love 233 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  2. HDU——T 1068 Girls and Boys

    http://acm.hdu.edu.cn/showproblem.php?pid=1068 Time Limit: 20000/10000 MS (Java/Others)    Memory Li ...

  3. 【hdu 1068】Girls and Boys

    [Link]:http://acm.hdu.edu.cn/showproblem.php?pid=1068 [Description] 有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人 ...

  4. HDU 3294 (Manacher) Girls' research

    变形的求最大回文子串,要求输出两个端点. 我觉得把'b'定义为真正的'a'是件很无聊的事,因为这并不会影响到最大回文子串的长度和位置,只是在输出的时候设置了一些不必要的障碍. 另外要注意一下原字符串s ...

  5. 【转载】图论 500题——主要为hdu/poj/zoj

    转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...

  6. hdu图论题目分类

    =============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...

  7. HDU图论题单

    =============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...

  8. HDU2063 过山车(二分匹配)

    过山车 HDU - 2063 RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做part ...

  9. hdu 2579 Dating with girls(2)

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...

随机推荐

  1. Android TextView 设置行间距

    Android系统中TextView默认显示中文时会比较紧凑,不是很美观.为了让每行保持一定的行间距,可以设置属性android:lineSpacingExtra或android:lineSpacin ...

  2. constraint和index--转载

    primary key和unique约束是要依赖index的,下面通过试验来看看他们之间的依赖关系!       SQL> select * from tt;   ID NA --------- ...

  3. PCB 奥宝LDI 输出自动改周期检测内容

    继续完善奥宝LDI输出,在自动更新周期发现前期梳理不过完善或出些从未考虑到的工艺问题, 今天将更改线路周期检测内容整理如下

  4. Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array -- 逆向思维

    原题中需要求解的是按照它给定的操作次序,即每次删掉一个数字求删掉后每个区间段的和的最大值是多少. 正面求解需要维护新形成的区间段,以及每段和,需要一些数据结构比如 map 和 set. map< ...

  5. SQlserver 当输入参数为可选条件

    以前很懒,都是用拼接字符串的方式,加上if 语句,根据输入参数是否为空来判断是否需要在where 后加上对应字段的条件限制 但是拼接字符串很烦,又总是被转义符搞得很烦  '''' 所以想了其他办法 分 ...

  6. CSS选择器优先级计算

    优先级从高到低排列,浏览器优先满足前面的规则 1,!important优先级最高 2,内联样式 3,作者>读者>浏览器 4,优先级权重加法 id选择器+100/个 类/伪类选择器+10/个 ...

  7. HTML5标签构成

    一个HTML5文件是由一些列的元素和标签组成的.元素是HTML5文件的重要组成部分,例如title(文件标题).img(图像)及table(表格)等.元素名不区分大小写,而HTML5用标签来规定元素的 ...

  8. Excel的用到的常规的技巧

    这几天在做各种发票的报表,好几百的数据当然离不开EXCel,自己又是个白班,就记录下啦! EXCEL 判断某一单元格值是否包含在某一列中 就在Excel的表格中加入这个函数:=IF(ISERROR(V ...

  9. CXF-JAX-RS开发(二)spring整合CXF-JAX-RS

    一.创建maven工程[Packaging:war] 1.目录结构 2.坐标书写 二.导入依赖和tomcat服务器插件 <dependencies> <!-- CXF --> ...

  10. SQLite 的使用

    private void button1_Click(object sender, EventArgs e) { //查询数据库内容并绑定 string sql= "select* from ...