#include<bits/stdc++.h> using namespace std; struct Sing{ string name; int time; int socre; }so[1010]; bool cmp(Sing a, Sing b){ if(a.socre!=b.socre){ return a.socre>b.socre; } else{ return a.name<b.name; } } int main(){ int n; while(cin>>n&&n!=0){ for(int i = 0; i<n; i++){ int m,s; char na[101]; scanf("%s %d:%d", na, &m, &s); so[i].name = na; so[i].time = m*60+s; so[i].socre = 0; } int k; cin>>k; for(int i=0; i<k; i++){ string na; cin>>na; int m,s; scanf("%d:%d", &m,&s); int time = m*60+s; for(int i = 0; i<n; i++){ if(so[i].name == na){ double bl = (double)time/so[i].time; if(bl<0.2){ so[i].socre+=0; } else if(bl<0.4){ so[i].socre +=1; } else if(bl<0.6){ so[i].socre+=2; } else if(bl<0.8){ so[i].socre +=3; } else if(bl<1){ so[i].socre += 4; } else{ so[i].socre +=5; } } } } sort(so, so+n, cmp); for(int i = 0; i<n; i++){ cout<<so[i].name<<" "<<so[i].socre<<endl; } } return 0; } |
Double click to view unformatted code.