hdu2093

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
int m;
struct node{
char name[];
int time,acno; }p[];
bool cmp(node a,node b){
if(a.acno==b.acno&&a.time==b.time) return (strcmp(b.name,a.name)>);
else if(a.acno==b.acno) return a.time<b.time;
else return a.acno>b.acno;
}
int change(char tmp[]){
int sum,res=,i,t=,k,j;
double cnt;
int l=strlen(tmp);
if(tmp[l-]==')'){
cnt=;
for(i=l-;tmp[i]!='(';--i){
k=;
for(j=;j<cnt;++j)
k*=;
t+= k * (tmp[i]-'');
cnt=cnt+;
}
tmp[i]='\0';
l=strlen(tmp);
}
cnt=;
for(i=l-;i>=;--i){
k=;
for(j=;j<cnt;++j)
k*=;
res+= k * (tmp[i]-'');
cnt=cnt+;
}
return res+t*m;
}
int main(){
int n,i,j,cnt=;
while(~scanf("%d%d",&n,&m)){
cnt=;
char tmp[];
for(j=;j<;++j){
scanf("%s",p[cnt].name);
p[cnt].acno=;
p[cnt].time=;
for(i=;i<n;++i){
scanf("%s",tmp);
if(tmp[]=='-'||tmp[]=='') continue;
else p[cnt].time+= change(tmp);
p[cnt].acno++;
}
cnt++;
}
sort(p,p+cnt,cmp);
for(i=;i<cnt;++i){
printf("%-10s %2d %4d\n",p[i].name,p[i].acno,p[i].time); }
}
return ;
}
上一篇:Spring in Action学习笔记(2)


下一篇:Grunt参考