View Code of Problem 100

#include<iostream> 
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef struct music{
      char name[100];
	  int time;
	  int score;	
}m;
bool cmp(m m1,m m2){
	if(m1.score!=m2.score)
	return m1.score>m2.score;
	else
	return strcmp(m1.name,m2.name)<0;
}
int main() {
	int n;
	while(scanf("%d",&n)!=EOF&&n!=0){
		m m1[n];
		int M,S;
		for(int i=0;i<n;i++){
			cin>>m1[i].name;
			scanf("%d:%d",&M,&S);
			m1[i].time=M*60+S;
			m1[i].score=0;
		}
		int m;
		cin>>m;
		while(m--)
		{
			char b[100];
			int M,S;
			cin>>b;
			scanf("%d:%d",&M,&S);
			int t=M*60+S;
			for(int i=0;i<n;i++){
				if(strcmp(b,m1[i].name)==0){
					m1[i].score+=5*t/m1[i].time;
				}
			}
		}
		sort(m1,m1+n,cmp);
		for(int i=0;i<n;i++){
		cout<<m1[i].name<<" "<<m1[i].score<<endl;
		}
	}
	 return 0;
}

Double click to view unformatted code.


Back to problem 100