B1047 编程团体赛 (20 分)

一、参考代码

#include<iostream>
#include<cstring> 
using namespace std;
int hashTable[1010];
int main(){
	int N;
	int group,id,score;//分别记录队号、成员号、分数
	cin >> N;
	int max = 0;// 记录总分最高的分数 
	int index = 0;//用于记录总分最高的队伍号 
	for(int i = 0; i < N; i++){
		scanf("%d-%d %d", &group, &id, &score);
		hashTable[group] += score;
		if(hashTable[group] > max){
			max = hashTable[group];
			index = group;
		}
	}
	cout << index << " " << max;
	return 0;
} 
posted @ 2019-11-07 10:56  睿晞  阅读(107)  评论(0编辑  收藏  举报