Topic links : https://pintia.cn/problem-sets/994805260223102976/problems/994805277163896832
Title Description
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
input of the first row is given a positive integer N (≤10 ^ 4), i.e., the total number of all team members. Then N rows, each player is given a score, in the format: Team number - number team scores, the ranks of which number is a positive integer of 1 to 1,000, players number is a positive integer from 1 to 10, 0 to 100 scores integer.
Output
Output champion 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 is
Sample Output
11176
Code
#include <cstdio>
int main() {
int n, team, id, score, max_team, max_scor = 0;
int hash[1010] = {0};
scanf("%d", &n);
while(n--) {
scanf("%d-%d %d", &team, &id, &score);
hash[team] += score;
if(hash[team] > max_scor) {
max_scor = hash[team];
max_team = team;
}
}
printf("%d %d\n", max_team, max_scor);
return 0;
}