算法初步——哈希表B1047.编程团体赛

 

 

#include <bits/stdc++.h>
#include<math.h>
#include <string>
using namespace std;
const int MAX_LEN = 10005;
//char str[MAX_LEN];
//int hashTable[30] = {0};
struct team{
    int teamnumber;
    int number;
    int grade;
}temp[MAX_LEN];
bool cmp(team a,team b){
    return a.grade > b.grade;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<MAX_LEN;++i){
        temp[i].grade = 0;
    }
    int teamnumber1,number1,grade1;
    for(int i =0;i<n;++i){
        scanf("%d-%d%d",&teamnumber1,&number1,&grade1);
        temp[teamnumber1].teamnumber = teamnumber1;
        temp[teamnumber1].number = number1;
        temp[teamnumber1].grade += grade1;
    }
    sort(temp,temp+MAX_LEN,cmp);
    cout<<temp[0].teamnumber<<" "<<temp[0].grade;
    system("pause");
    return 0;
} 
 
posted @ 2020-01-07 14:22  JasonPeng1  阅读(158)  评论(0编辑  收藏  举报