PRoblem Link:http://139.129.36.234/problem.php?id=1208
1 S 08:102 S 08:351 E 10:002 E 13:160 S 17:000 S 17:003 E 08:101 S 08:202 S 09:001 E 09:200 E 17:00-1样例输出
2 1960 01 60提示
来源
2007年浙江大学计算机及软件工程研究生机试真题
AC code:
#include<iostream>#include<algorithm>#include<stdio.h>#include<map>#include<math.h>#include<string.h>#include<queue>#include<vector>#include<set>#define LL long long#define exp 1e-9#define MAXN 1000010using namespace std;int sum,cnt,num,h,m;char ch;int mark[111],sth[111],stm[111];int jishi(int h1,int m1,int h2,int m2){ int sum=0; if(h1<h2) { sum+=60-m1; h1++; } sum+=(h2-h1)*60+m2; return sum;}int main(){// freopen("D://in.txt","r",stdin); memset(mark,0,sizeof(mark)); sum=cnt=0; while(scanf("%d",&num)!=EOF) { if(num==-1) break; if(num==0) { if(cnt==0) printf("0 0/n"); else printf("%d %.0lf/n",cnt,sum*1.0/cnt); memset(mark,0,sizeof(mark)); sum=cnt=0; } scanf(" %c %d:%d/n",&ch,&h,&m); if(ch=='S') { mark[num]=1; sth[num]=h; stm[num]=m; } else if(ch=='E') { if(mark[num]==1) { cnt++; sum+=jishi(sth[num],stm[num],h,m);// printf("%d:%d/n",num,jishi(sth[num],stm[num],h,m)); mark[num]=0; } } } return 0;}
新闻热点
疑难解答