topic
Rules for Programming Team: Each team composed of players if, dry; all the players attention immediately ⽐ alone game; teams score of all the players and the results; the results of the most ADVANCED team wins. Now given all the players ⽐ season record, would you please write a program to find the winning team.
START input format:
input START ⼀ first frame ⾏ given positive integer N (<= 10000), i.e., the total number of all team members. N ⾏ Subsequently, each ⾏ gives players performance ⼀ bit format: "Team number - number team score", wherein "team ID" is a positive integer of 1 to 1,000, "player ID" is a positive integer from 1 to 10 "score" is an integer from 0 to 100.
Output formats:
Output championship team number and total score in ⼀ ⾏ in the meantime it at an separate spaces. Note: The destination time title winning team is the only guarantee of ⼀.
Sample input START:
. 6
3-10 99
11-5 87
102-1 0
102-3 100
11-9 89
3-2 61 is
a sample output:
11,176
Topic analysis
- Team number gn (gn> = 1 && gn <= 1000), the team corresponding to subscript numbers ASC define an array, the size is set to 1001, recording the team score
- Team players score superimposed, recorded asc array
- Max use subscripts recorded maximum score, and if the equal fraction appears max <under the current standard, the current index = max (score equivalent, taking the smallest number team)
The same score championship appearance, the subject did not inform how to deal with test results
- (The same score champion, taking the lowest-numbered print team, can all be AC)
- (The same score champion, take any one of (without any treatment), can all be AC)
code
code 01
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
int N,gn,pn,sc;
scanf("%d",&N);
int asc[1001]= {0};
int max=0;
for(int i=0; i<N; i++) {
scanf("%d-%d %d",&gn,&pn,&sc);
asc[gn]+=sc;
if(asc[max]<asc[gn])max=gn;
//if(asc[max]==asc[gn]&&max<gn)max=gn;//同等分数冠军,处理和不处理,取任何一个,测试都可以全部AC
}
printf("%d %d",max,asc[max]);
}