1047. Programming Team (20)
The rules of the programming team are: Each of the teams is composed of a number of players, all players are independent of the competition, the team's results for all the team's performance and the highest-score team wins.
Now given the results of all players, please write a program to find the champions team.
Input format:
Enter the first line to give a positive integer n (<=10000), that is, the total number of participants. Then n rows, each line gives a player's score in the form: "Team number-player number score", where "team number" is a positive integer from 1 to 1000, "player number" is a positive integer of 1 to 10, and "score" is an integer of 0 to 100.
Output format:
The number and total score of the Champions team are output in one line, separated by a single space. Note: The title Guarantee team is unique. Input Sample:
6
3-10
11-5
102-1 0
102-3
11-9
3-2 61
Output Sample:
11 176
C++
#include <iostream>
using namespace std;
int main () {
int n;//total number
of players int duiwu,duiyuan,chengji;//team number, player number, score
int maxduiwu=0,maxchengji=0;// Highest-scoring team, highest score
int score[10001]={0};//score array record score
cin>>n;
for (int i=0;i<n;i++) {
scanf ("%d-%d%d", &duiwu,&duiyuan,&chengji);//%d input integer
score[duiwu]= score[duiwu]+chengji;//Statistic Team score
if (Score[duiwu]>maxchengji) {//traverse highest
Maxchengji=score[duiwu];
Maxduiwu=duiwu
}
}
cout<<maxduiwu<< "" <<maxchengji;
return 0;
}