PAT program 1047 Team B (20 minutes)

Programming Team 1047 (20 minutes)

Rules for Programming Team: Each team composed of several members; all members of the independent game; teams score of all the players and the results; the highest team score wins.
Now given all the players race results, you write a program to find the winning team.
Input formats:

The first input line is given a positive integer N (≤104), i.e., the total number of all team members. Then N rows, each player is given a score, in the format: Team number - number team scores, the ranks of which number is a positive integer of 1 to 1,000, players number is a positive integer from 1 to 10, 0 to 100 scores integer.
Output formats:

Output championship team number and total score in a row, during which separated by a space. Note: The title winning team is the only guarantee.
Sample input:

. 6
3-10 99
11-5 87
102-1 0
102-3 100
11-9 89
3-2 61 is
a sample output:

11176
Author: CHEN, Yue
units: Zhejiang University
Time limit: 400 ms
Memory Limit: 64 MB
Code length limit: 16 KB

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,store[1005]={0},score,temp,id;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        scanf("%d-%d %d",&id,&temp,&score);
        store[id]+=score;
    }
    cout<<max_element(store,store+1000) - store <<" "<< *max_element(store,store+1000);
    return 0;
}
Published 101 original articles · won praise 50 · views 8277

Guess you like

Origin blog.csdn.net/qq_43422111/article/details/104106888