1305.cpp

来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 52 行

CPP
52 行
字号
/*  This Code is Submitted by wywcgs for Problem 1305 on 2005-03-20 at 08:09:13 */ 
#include <stdio.h>
#include <string.h>

typedef struct{
    char name[81];
    int problemSloved;
    int penaltyPoints;
}Team;

void teamcpy(Team*, Team*);

int main()
{
    Team MAX, temp;
    int teamNum, slvTimes, petPoints;
    int i, j;
    
    while(scanf("%d", &teamNum) == 1){
        for(i = 0; i < teamNum; i++){
            temp.problemSloved = 0;
            temp.penaltyPoints = 0;
            scanf("%s", temp.name);
            for(j = 0; j < 4; j++){
                scanf("%d %d", &slvTimes, &petPoints);
                if(petPoints != 0){
                    temp.problemSloved++;
                    temp.penaltyPoints += (slvTimes - 1) * 20 + petPoints;
                }
            }    
            if(i == 0){
                teamcpy(&MAX, &temp);
            }else{
                if(MAX.problemSloved < temp.problemSloved){
                    teamcpy(&MAX, &temp);
                }else if((MAX.problemSloved == temp.problemSloved) && (MAX.penaltyPoints > temp.penaltyPoints)){
                    teamcpy(&MAX, &temp);
                }    
            }
        }
        printf("%s %d %d\n", MAX.name, MAX.problemSloved, MAX.penaltyPoints);
    }

    return 0;
}

void teamcpy(Team* dest, Team* src)
{
    dest->problemSloved = src->problemSloved;
    dest->penaltyPoints = src->penaltyPoints;
    strcpy(dest->name, src->name);
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?