PAT1032. Excavator technology which strong (20)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.