Excavator Technology (c ++)
Description: An excavator skill competition is organized to show which excavator technology is strong. Please calculate the most technically competent school based on the competition results.
Input: enter a positive integer N of no more than 1st in row 105, that is, the number of participants. In the next N rows, each row provides information and scores of a contestant, including the number of the school it represents (from 1), and the score of the competition (percentage ), separated by spaces.
Output: the number and total score of the school with the highest total score are given in a row. Separate the numbers with spaces in the middle. The answer to the question must be unique.
Input:
6 3 65 2 80 1 100 2 70 3 40 3 0
Output:
2 150
1 #include<iostream> 2 using namespace std; 3 4 int judge(int a[][2], int j,int k) 5 { 6 for (int i = 0; i < j; i++) 7 { 8 if (a[i][0] == k) 9 return i;10 }11 return -1;12 }13 int main()14 {15 int n,j=0;16 cin >> n;17 int a[100][2];18 for (int i = 0; i < n; i++)19 {20 int x, y, z;21 cin >> x >> y;22 z = judge(a, j, x);23 if (z >= 0)24 a[z][1] += y;25 else26 {27 a[j][0] = x; a[j][1] = y;28 j++;29 }30 }31 int max = 0;32 for (int i = 0; i < j; i++)33 {34 if (a[i][1]>a[max][1])35 max = i;36 }37 cout << a[max][0] << " " << a[max][1] << endl;38 delete []a;39 system("pause");40 return 0;41 }