1 题目
2 代码
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class B1047 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int[] hash = new int[1001];
for (int i = 0; i < N; i++) {
String[] line = br.readLine().split(" ");
int team = Integer.parseInt(line[0].split("-")[0]);
hash[team] += Integer.parseInt(line[1]);
}
int res = 0;
int maxGrade = 0;
for (int i = 1; i < 1001; i++) {
if (hash[i] > maxGrade) {
res = i;
maxGrade = hash[i];
}
}
System.out.println(res + " " + maxGrade);
}
}
3 要点
(1)建立Hash表映射存储每个队伍的总成绩,遍历出最高成绩的队伍编号即可。