注意:连续的S和E才算一次借还
代码:
#include<iostream> #include<cstdio> using namespace std; typedef struct { int id; char record; int m; } P; int main() { int n; scanf("%d", &n); while(n--) { P c[10000]; int id, a, b; char record; int cur = 0, count = 0; double sum = 0; while(1) { scanf("%d %c %d:%d", &id, &record, &a, &b); if(id) { c[cur].id = id; c[cur].record = record; c[cur].m = a*60 + b; cur++; } else { for(int i = 0; i < cur; i++) { if(c[i].record == ‘S‘) for(int j = i+1; j < cur; j++) { if(c[j].record == ‘S‘ && c[i].id == c[j].id) break; if(c[j].record == ‘E‘ && c[i].id == c[j].id) { sum += c[j].m - c[i].m; count++; break; } } } if(count) printf("%d %d\n", count, (int)((sum/count)+0.5)); else printf("0 0\n"); break; } } } return 0; }
原文地址:https://www.cnblogs.com/kindleheart/p/8669082.html
时间: 2024-10-09 19:31:57