《数据结构编程实验》 1.5.4A Contesting Decision

来源:互联网 发布:pc1500 水利计算软件 编辑:程序博客网 时间:2024/04/30 12:43

题目大意:

  统计每个参赛队的解题数及罚时,输出优胜队。


题目地址:

  POJ  1581 ZOJ  1764 UVA  2832


题解:

  语法水题一道。


#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){    char wname[256],tname[256];    int n;    int a[5],b[5];    int wpro,wtime,tpro,ttime;    int i,j;    scanf("%d",&n);    wpro=0;wtime=0;    scanf("%s%d%d%d%d%d%d%d%d",wname,&a[1],&b[1],&a[2],&b[2],&a[3],&b[3],&a[4],&b[4]);    for (j=1;j<5;j++) if (b[j]) {wpro++;wtime=wtime+b[j]+20*(a[j]-1);}    for (i=1;i<n;i++)    {        scanf("%s%d%d%d%d%d%d%d%d",tname,&a[1],&b[1],&a[2],&b[2],&a[3],&b[3],&a[4],&b[4]);        tpro=0;ttime=0;        for (j=1;j<5;j++) if (b[j]) {tpro++;ttime=ttime+b[j]+20*(a[j]-1);}        if (tpro>wpro||(tpro==wpro&&ttime<wtime)) {strcpy(wname,tname);wpro=tpro;wtime=ttime;}    }    printf("%s %d %d\n",wname,wpro,wtime);    return 0;}


0 0