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
#include <iostream> using namespace std; int main() { int T; cin>>T; int arr[T+1]={0},a,b;//这边数组记得加一 for(int i=0;i<T;i++){ cin>>a>>b; arr[a]+=b; } int maxNum=0,maxScore=-1; for(int i=0;i<T+1;i++){ if(arr[i]>maxScore) { maxNum=i; maxScore=arr[i]; } } cout<<maxNum<<" "<<maxScore; system("pause"); return 0; }
This question of time and memory cards