Programming Team 1047 (20 minutes)
Link to the original question: Portal
I, entitled:
Second, resolve:
AC Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int[] troops = new int[1001];
int champion = 0, max = 0;
Integer N = Integer.valueOf(in.readLine());
for (int i = 0; i < N; i++) {
String[] split = in.readLine().split(" ");
String[] front = split[0].split("-");
int id = Integer.valueOf(front[0]);
int score = Integer.valueOf(split[1]);
troops[id] += score;
if (troops[id] > max) {
champion = id;
max = troops[id];
}
}
System.out.print(champion+" "+max);
}
}