#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int school[maxn] = {0}; int main(int argc, char* argv[]) { int N, id, score, max_id, max_score = 0; cin >> N; for(int i = 0; i < N; i++) { cin >> id >> score; school[id] += score; } for(int i = 0; i < N; i++){ if(school[i] > max_score){ max_id = i; max_score = school[i]; } } cout << max_id << ‘ ‘ << max_score << endl; return 0; }
原文:https://www.cnblogs.com/YC-L/p/12274674.html