#include <stdio.h> #include <cstring> #include <iostream> using namespace std; int main() { int n, m; while(~scanf("%d", &n) && n){ getchar(); char input[n][100], tmp[100]; int mm,ss, score[n] = {0}; double time[n]; for(int i = 0; i < n; i++){ scanf("%s %d:%d", input[i], &mm, &ss); getchar(); time[i] = double(mm*60+ss); } scanf("%d", &m); getchar(); double tmpTime; while(m--){ scanf("%s %d:%d", tmp, &mm, &ss); getchar(); for(int i = 0; i < n; i++){ if(!strcmp(tmp, input[i])){ tmpTime = double(mm*60+ss); if(tmpTime >= (time[i]*0.2) && tmpTime < (time[i]*0.4)){ score[i] += 1; } else if(tmpTime >= (time[i]*0.4) && tmpTime < (time[i]*0.6)){ score[i] += 2; } else if(tmpTime >= (time[i]*0.6) && tmpTime < (time[i]*0.8)){ score[i] += 3; } else if(tmpTime >= (time[i]*0.8) && tmpTime < time[i]){ score[i] += 4; } else if(tmpTime >= time[i]){ score[i] += 5; } } } } char output[n][100]; for(int i = 1; i < n; i++){ for(int j = i; j >= 1; j--){ if(score[j-1] < score[j]){ swap(score[j-1], score[j]); swap(input[j-1], input[j]); } else if(score[j-1] == score[j]){ if(strcmp(input[j-1], input[j]) > 0){ swap(input[j-1], input[j]); } } } } for(int i = 0; i < n; i++){ cout << input[i] << " " << score[i] << endl; } } return 0; } |
Double click to view unformatted code.