hdu2093

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
int m;
struct node{
    char name[100];
    int time,acno;

}p[100];
bool cmp(node a,node b){
    if(a.acno==b.acno&&a.time==b.time) return (strcmp(b.name,a.name)>0);
    else if(a.acno==b.acno)  return a.time<b.time;
    else                return a.acno>b.acno;
}
int change(char tmp[]){
    int sum,res=0,i,t=0,k,j;
    double cnt;
    int l=strlen(tmp);
    if(tmp[l-1]==')'){
        cnt=0;
        for(i=l-2;tmp[i]!='(';--i){
            k=1;
            for(j=0;j<cnt;++j)
                k*=10;
            t+= k * (tmp[i]-'0');
            cnt=cnt+1;
        }
        tmp[i]='\0';
        l=strlen(tmp);
    }
    cnt=0;
    for(i=l-1;i>=0;--i){
        k=1;
        for(j=0;j<cnt;++j)
            k*=10;
        res+= k * (tmp[i]-'0');
        cnt=cnt+1;
    }
    return res+t*m;
}
int main(){
    int n,i,j,cnt=0;
    while(~scanf("%d%d",&n,&m)){
        cnt=0;
        char tmp[100];
            for(j=0;j<6;++j){
            scanf("%s",p[cnt].name);
            p[cnt].acno=0;
            p[cnt].time=0;
            for(i=0;i<n;++i){
                scanf("%s",tmp);
                if(tmp[0]=='-'||tmp[0]=='0') continue;
                else p[cnt].time+= change(tmp);
                p[cnt].acno++;
            }
            cnt++;
        }
        sort(p,p+cnt,cmp);
        for(i=0;i<cnt;++i){
            printf("%-10s %2d %4d\n",p[i].name,p[i].acno,p[i].time);

        }
    }
    return 0;
}

 

posted on 2013-11-08 16:18 symons 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/symons1992/p/3414509.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值