1047 編程團體賽 (20 分)
編程團體賽的規則爲:每個參賽隊由若干隊員組成;所有隊員獨立比賽;參賽隊的成績爲所有隊員的成績和;成績最高的隊獲勝。
現給定所有隊員的比賽成績,請你編寫程序找出冠軍隊。
輸入格式:
輸入第一行給出一個正整數 N(≤104),即所有參賽隊員總數。隨後 N 行,每行給出一位隊員的成績,格式爲:隊伍編號-隊員編號 成績
,其中隊伍編號
爲 1 到 1000 的正整數,隊員編號
爲 1 到 10 的正整數,成績
爲 0 到 100 的整數。
輸出格式:
在一行中輸出冠軍隊的編號和總成績,其間以一個空格分隔。注意:題目保證冠軍隊是唯一的。
輸入樣例:
6
3-10 99
11-5 87
102-1 0
102-3 100
11-9 89
3-2 61
輸出樣例:
11 176
#include<iostream>
#include<cstdio>
using namespace std;
struct m
{
int number;//隊伍編號
int number1;//隊員編號
int score;//成績
}champion[1002];
int main()
{
int n;//隊伍總數
cin>>n;
int max1=0,max2=0;
champion[0].score=0;
champion[0].number=0;
champion[0].number1=0;
for(int i=0;i<n;i++)
{
scanf("%d-%d %d",&champion[0].number,&champion[0].number1,&champion[0].score);
champion[champion[0].number].number=champion[0].number;
champion[champion[0].number].number1=champion[0].number1;
champion[champion[0].number].score+=champion[0].score;
//printf("%d",champion[].score);
}
for(int i=1;i<1001;i++)
{
// if(champion[i].number!=0)
// {
// printf("%d\n",champion[i].score);
// }
if(max1<champion[i].score)
{
max1=champion[i].score;
max2=champion[i].number;
}
}
printf("%d %d",max2,max1);
return 0;
}