Excavator Technology (c ++)

Source: Internet
Author: User

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 }

 

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: info-contact@alibabacloud.com 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.