#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
struct edg
{
char s[100];
int sum,ac,flag;
}e[10000];
int cmp(const void *a,const void *b)
{
if(((struct edg *)a)->flag!=((struct edg *)b)->flag)
return ((struct edg *)b)->flag-((struct edg *)a)->flag;
else
{
if(((struct edg *)a)->sum!=((struct edg *)b)->sum)
return ((struct edg *)a)->sum-((struct edg *)b)->sum;
else
return strcmp(((struct edg *)a)->s,((struct edg *)b)->s);
}
}
int main()
{
int n,m,i=0;
char t[100];
scanf("%d%d",&n,&m);
while(scanf("%s",e[i].s)!=EOF)
{
int a,b;
e[i].sum=e[i].ac=e[i].flag=0;
for(int j=0;j<n;++j)
{
int max=0;
a=0;b=0;
scanf("%s",t);
int c=strlen(t);
if(t[0]=='-'||!(t[0]-'0')) continue;
else
{
e[i].flag++;
if(t[c-1]==')')
{
int k=0;
while(t[k]!='(')
{
a=a*10+(t[k]-'0');
k++;
}
k++;
while(t[k]!=')')
{
b=b*10+(t[k]-'0');
k++;
}
e[i].sum+=a;
e[i].ac+=b;
}
else
e[i].sum+=atoi(t);
}
}
e[i].sum+=e[i].ac*m; i++;
}
qsort(e,i,sizeof(e[0]),cmp);
for(int j=0;j<i;++j)
printf("%-10s %2d %4d\n",e[j].s,e[j].flag,e[j].sum);
// system("pause");
return 0;
}
hdu2093 考试排名
最新推荐文章于 2022-02-25 19:38:17 发布