题目链接
https://www.nowcoder.com/pat/6/problem/4058
代码
#include<iostream>
#include<string.h>
#define MAX 100005
using namespace std;
int main() {
int n, t, k;
int index, max_value=0;
int a[MAX];
memset(a, 0, sizeof(a));
scanf("%d", &n);
for(int i=0; i<n; i++) {
scanf("%d%d",&k,&t);
a[k] += t;
if(a[k] > max_value) {
index = k;
max_value = a[k];
}
}
printf("%d %d\n", index, max_value);
return 0;
}