PAT-GPLT訓練集 L1-043 閱覽室
阿新 • • 發佈:2018-03-29
using pri log names %d contest for https blank
PAT-GPLT訓練集 L1-043 閱覽室
註意:連續的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; }
PAT-GPLT訓練集 L1-043 閱覽室