hdu3040 Happy Girls 水题

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3040

水题,排个序就好了。

hdu3040 Happy Girls 水题
 1 ///2014.4.3 - 2014.4.5
 2 ///hdu3040
 3 
 4 ///203MS
 5 
 6 #include <iostream>
 7 #include <cstdio>
 8 #include <algorithm>
 9 #include <cstring>
10 using namespace std;
11 
12 struct Vote{
13     int time;
14     long long tel;
15     int  num;
16 };
17 
18 int N;
19 int girlGet[11];
20 int numOfVote;
21 Vote vote[50100];
22 
23 void init(){
24     memset(girlGet,0,sizeof(girlGet) );
25     numOfVote = 0;
26 
27     int h,m,s;
28     unsigned long long tel;
29     int num;
30     while( scanf("%d",&h)==1 ){
31         scanf(":%d:%d %llu %d\n",&m,&s,&tel,&num);
32         vote[numOfVote].time = h*3600 + m*60 + s ;
33         vote[numOfVote].tel = tel;
34         vote[numOfVote].num = num;
35         numOfVote++;
36     }
37     scanf("#end\n");
38 }
39 
40 bool cmp(Vote A,Vote B){
41     if(A.tel > B.tel)
42         return false;
43     else if(A.tel < B.tel)
44         return true;
45     else
46         return A.time < B.time;
47 }
48 
49 int main()
50 {
51     // freopen("in","r",stdin);
52     // freopen("out","w",stdout);
53 
54     while( cin>>N ){
55         init();
56         sort(vote,vote+numOfVote,cmp);
57         
58         girlGet[ vote[0].num ]++;
59         int ti  = vote[0].time;
60         for(int i=1 ; i<numOfVote ; i++){
61             if( vote[i].tel==vote[i-1].tel ){
62                 if( vote[i].time-ti >= 60 ){
63                     ti = vote[i].time;
64                     girlGet[ vote[i].num ]++;
65                 }
66             }
67             else{
68                 ti = vote[i].time;
69                 girlGet[ vote[i].num ]++;
70             }
71         }
72 
73         cout<<"The result is :"<<endl;
74         for(int i=1 ; i<=N ; i++){
75             printf("%02d : ",i );
76             for(int j=0 ; j<girlGet[i] ; j++){
77                 printf("*");
78             }
79             cout<<endl;
80         }
81     }
82     return 0;
83 }
hdu3040 Happy Girls 水题

 

hdu3040 Happy Girls 水题,布布扣,bubuko.com

hdu3040 Happy Girls 水题

上一篇:阿里安全峰会:云安全的未来是什么样子的?


下一篇:iOS开发------之runtime的运用-类与对象&&&获取当前网络状态