Rules for Programming Team: Each team composed of several members; all members of the independent game; teams score of all the players and the results; the highest team score wins.
Now given all the players race results, you write a program to find the winning team.
Input formats:
The first input line is given a positive integer N ( ≤), i.e., the total number of all team members. Then N rows, each player is given a score, the format is: 队伍编号-队员编号 成绩
where 队伍编号
is a positive integer of 1 to 1,000, 队员编号
is a positive integer from 1 to 10, 成绩
an integer of 0 to 100.
Output formats:
Output championship team number and total score in a row, during which separated by a space. Note: The title winning team is the only guarantee.
Sample input:
6
3-10 99
11-5 87
102-1 0
102-3 100
11-9 89
3-2 61
Sample output:
11 176
#include <iostream> #include <cstdlib> using namespace std; int main(){ int teamNum[1001]={0},team,max,score,T; cin>>T; while(T--){ scanf("%d-%d %d",&team,&max,&score); teamNum[team]+=score; } max=0; for(int i=0;i<1001;i++){ if(teamNum[i]>teamNum[max]) max=i; } cout<<max<<" "<<teamNum[max]; system("pause"); return 0; }