import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Map<Integer,Integer> map = new HashMap<>();
int max = -1;
int max_num = -1;
for(int i = 0 ; i < n ; i++) {
int num = sc.nextInt();
int score = sc.nextInt();
if(map.containsKey(num)) {
map.put(num, map.get(num) + score);
} else {
map.put(num, score);
}
if(max < map.get(num)) {
max = map.get(num);
max_num = num;
}
}
System.out.println(max_num + " " + max);
}
}
以上代码,在牛客网可以通过,但是在官网只能部分正确。因为官网限制在200ms 目前没想到改进方法,以后想到了再来改进