题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805277163896832
又是一道水题,知道使用哈希表以后就很简单了,题目中的队员编号没有使用到,思路与算法笔记基本一致
代码
#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){int n;int tempID,tempStu, tempScore;vector<int> hashtable(1000);scanf("%d",&n);for(int i = 0; i < n; i++){scanf("%d-%d %d",&tempID, &tempStu, &tempScore);hashtable[tempID] += tempScore;}int maxi = 0;for(int i = 0; i < 1000; i++){if(hashtable[i]>hashtable[maxi])maxi = i;}printf("%d %d",maxi,hashtable[maxi]);}
