Description
Input
Output
Sample Input
Sample Output
4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
4 06:30:17
1
0 00:00:00
-1
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct student { int problem; int score; int time; int bianhao; }; struct a { int times[110]; int count; }; bool cmp(student stud1,student stud2) { if(stud1.problem!=stud2.problem) { return stud1.problem>stud2.problem; } else { return stud1.time<stud2.time; } } bool cmp1(student stud1,student stud2) { return stud1.bianhao<stud2.bianhao; } int main() { #ifdef CDZSC_OFFLINE freopen("in.txt","r",stdin); #endif int n,i,h,m,s; student stud[110]; a studs[6]; while(scanf("%d",&n)&&n!=-1) { for(i=0; i<6; i++) { studs[i].count=0; } for(i=0; i<n; i++) { scanf("%d",&stud[i].problem); scanf("%d:%d:%d",&h,&m,&s); stud[i].time=h*3600+m*60+s; stud[i].score=50+10*stud[i].problem; stud[i].bianhao=i; } sort(stud,stud+n,cmp); for(i=0; i<n; i++) { studs[stud[i].problem].times[studs[stud[i].problem].count]=stud[i].time; studs[stud[i].problem].count++; } for(i=0; i<n; i++) { if(stud[i].problem!=5&&stud[i].problem!=0&&stud[i].time<=studs[stud[i].problem].times[studs[stud[i].problem].count/2-1]) { stud[i].score+=5; } } sort(stud,stud+n,cmp1); for(i=0; i<n; i++) { printf("%d\n",stud[i].score); } printf("\n"); } return 0; }
原文:http://www.cnblogs.com/Wing0624/p/4244406.html