#include
#include
#include
using namespace std;
struct student
{
char name[11];
int solve;
int cost;
}stu[10000];
bool cmp(student a,student b)
{
if(a.solve!=b.solve)
if(a.solve>b.solve)
return true;
else
return false;
else if(a.cost==b.cost)
{
return(strcmp(a.name,b.name)<0);
}
else
return(a.cost<b.cost);
}
int main()
{
int n,m,i,s,k;
char ch;
while(cin>>n>>m)
{
int t=0;
while(cin>>stu[t].name)
{
if(strcmp(stu[t].name,"eof")==0)
break;
for(i=0;i
{
cin>>s;
if(s>0)
{
stu[t].solve++;
k=0;
if(getchar()=='(')
{
cin>>k;
cin>>ch;
}
stu[t].cost=stu[t].cost+s+k*m;
}
}
t++;
}
sort(stu,stu+t,cmp);
for(i=0;i<t;i++)
cout<<left<<setw(10)<<stu[i].name<<' '<<right<<setw(2)<<stu[i].solve<<' '<<setw(4)<<stu[i].cost<<endl;
}
return 0;
}
最好給出題目和輸入輸出數據。