1047 编程团体赛 (20分)

1047 编程团体赛 (20分)



原题链接:传送门

一、题目:

70)

二、解析:

AC代码:

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);
	}
}
发布了99 篇原创文章 · 获赞 105 · 访问量 9355

猜你喜欢

转载自blog.csdn.net/weixin_44034328/article/details/104080777