PAT B-1032 strong Which Excavator

Which strong Excavator 1032 (20 minutes)
 

To illustrate the facts Excavator Which in the end strong, PAT excavator organized a skills competition. Now you that the statistics of the strongest technical schools based on results of the competition.

Input formats:

Input is given in the first line does not exceed  a positive integer  N, i.e. the number of entries. Then  N lines, each and every participant is given the information and results, including the school they represent numbers (starting with 1 numbered consecutively), and game scores (percentile), separated by a space.

Output formats:

Given the highest total score in a row, the number of schools, and their total score, separated by a space. The only answer is to ensure that the subject is not tied.

Sample input:

6
3 65
2 80
1 100
2 70
3 40
3 0

Sample output:

2 150
Implementation:
# include <cstdio>
int main () {
int school[100005]={0};
int n,score,schoolID;
int max=0,temp=1;
scanf("%d", &n);
for (int i = 0; i <n; i ++) {// do ... while here can not be used while the structure or changing the value of n
scanf("%d%d", &schoolID, &score);
school [schoolID] + = score; // index ID in place of the school
}
for (int i = 1; i <= n; i ++) {// find the maximum value of enum
if(school[i]>max){
max=school[i];
temp=i;
}
}
printf("%d %d\n", temp, max);
return 0;

}

Guess you like

Origin www.cnblogs.com/lzdxh027/p/11305322.html