时隔多年,也是终于纯纯靠自己写出来了,这种感觉确实是比当初背代码的感觉要好一些。哎,还是得要纯纯地靠自己思考下刷题才是有效的啊。
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+10;
struct shu{
int time;
int st;
}shus[N];
struct day{
int cnt;
int total;
int pj;
}days[20];
int main(){
int n;
cin>>n;
int shuhao;
char caozuo;
int hh,mm;
for(int i=0;i<n;){
scanf("%d %c %d:%d",&shuhao,&caozuo,&hh,&mm);
if(caozuo == 'S'){
shus[shuhao].time = hh * 60 + mm;
shus[shuhao].st = 1;
}
if(caozuo == 'E'){
if(shus[shuhao].st == 1){
days[i].cnt++;
days[i].total += hh * 60 + mm - shus[shuhao].time;
shus[shuhao].st = 0;
}
}
if(shuhao == 0){
double l = days[i].cnt;
double p = days[i].total;
if(l == 0){
cout<<0<<" "<<0<<endl;
}
else{
cout<<l<<" "<<int(p/l + 0.5) <<endl;
}
i++;
memset(shus , 0 ,sizeof shus);
}
}
}