这题也是写了可长时间: #include <stdio.h> #include <iostream> #include <stack> #include <string.h> #include <queue> #include <cmath> #include <vector> #include <algorithm> #include <map> #include <set> #include <string> using namespace std; typedef long long LL; map<int, char> a; map<int, int> b; int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt","w",stdout); int n; cin >> n; while(n--){ double time = 0; int sum = 0; a.clear(); b.clear(); int num, begin, end; char status; while(scanf("%d %c %d:%d", &num, &status, &begin, &end)){ if(num == 0) break; if(status == 'S'){ a[num] = 'S'; b[num] = begin * 60 + end; } if(status == 'E'){ if(a[num] == 'S'){ time += begin * 60 + end - b[num]; sum ++; a[num] = '0'; } } } if(sum != 0){ time = time / sum; } int t = time + 0.5; printf("%d %d ",sum,t); } return 0; }