In order to use the fact that the excavator technology in the end which strong, Pat organized an excavator skills contest. You are now asked to count the most technically powerful schools according to the results of the match.
Input format:
The input gives a positive integer n of no more than 105 in line 1th, which is the number of participants. Then n rows, each row gives a contestant's information and results, including the number of the school they represent (consecutively numbered from 1), and their race results (percentile), separated by a space.
Output format:
Give the number of the school with the highest score in a row, and its total score, separated by a space. The title ensures that the answer is unique and not tied.
Input Sample:
63 652 801 1002 703 403 0
Sample output:
2 150
Idea: Counting sort
1#include <stdio.h>2#include <string.h>3 intscore[100010];4 5 intMainintargcChar*argv[])6 {7memset (Score,0,sizeof(score));8 intcount;9 intmaxpt;Ten BOOLflag=true; Onescanf"%d",&count); A while(count--) - { - intSchool,grade; thescanf"%d%d",&school,&grade); - if(flag) - { -flag=false; +maxpt=School; - } +score[school]+=grade; A if(score[school]>SCORE[MAXPT]) at { -maxpt=School; - } - } -printf"%d%d\n", MAXPT,SCORE[MAXPT]); - in return 0; -}
View Code
PAT1032. Excavator technology which strong (20)