Qiuqiqiu  
不管道路多么崎岖坎坷,我永远不停下追逐梦想的脚步!

http://acm.hdu.edu.cn/showproblem.php?pid=2093

 

View Code
 1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 struct student
5 {
6 char name[15];
7 int s,t;
8 }a[1000];
9 char s1[15];
10 int n=0,m,tt;
11 int cmp(const void *a,const void *b)
12 {
13 student *a1=(student*)a;
14 student *b1=(student*)b;
15 if (a1->s != b1->s) return b1->s - a1->s;
16 if (a1->t != b1->t) return a1->t - b1->t;
17 return strcmp(a1->name,b1->name);
18 }
19 int time(char *s)
20 {
21 int t1=0,i,j,t2=0;
22 for (i=0;s[i]!='(' && s[i];i++) t1=t1*10+s[i]-'0';
23 if(s[i]) for (j=i+1;s[j]!=')';j++) t2=t2*10+s[j]-'0';
24 return t1+t2*tt;
25 }
26 int main()
27 {
28 scanf("%d%d",&m,&tt);
29 while (scanf("%s",&a[++n].name)!=EOF)
30 {
31 a[n].s=a[n].t=0;
32 for (int i=1;i<=m;i++)
33 {
34 scanf("%s",s1);
35 if (s1[0]=='0' || s1[0]=='-') continue;
36 a[n].s++;
37 a[n].t+=time(s1);
38 }
39 }
40 n--;
41 qsort(a+1,n,sizeof(a[0]),cmp);
42 for (int i=1;i<=n;i++) printf("%-10s %2d %4d\n",a[i].name,a[i].s,a[i].t);
43 return 0;
44 }

 

posted on 2011-11-26 15:10  Qiuqiqiu  阅读(349)  评论(0编辑  收藏  举报