Programming Team 1047 (20 minutes)

Programming Team 1047 (20 minutes)



Link to the original question: Portal

I, entitled:

70)

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);
	}
}
Published 99 original articles · won praise 105 · Views 9355

Guess you like

Origin blog.csdn.net/weixin_44034328/article/details/104080777