输入样例:
6
3 65
2 80
1 100
2 70
3 40
3 0
输出样例:
2 150
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int number = Integer.parseInt(bf.readLine().replace("\\s+", "")), max = 1, temp = 1;
HashMap<Integer,Integer> map = new HashMap<>();
for(int i = 0; i < number; i ++) {
String[] str = bf.readLine().split("\\s+");
if(!map.containsKey(Integer.parseInt(str[0]))) {
map.put(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
} else {
map.put(Integer.parseInt(str[0]), (map.get(Integer.parseInt(str[0])) + Integer.parseInt(str[1])));
}
}
bf.close();
while(map.containsKey(temp)) {
if(map.get(max) < map.get(temp)) {
max = temp;
}
temp ++;
}
System.out.println(max + " " + map.get(max));
}
}