QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#24259#2291. Lopsided LineupjskopRE 0ms0kbJava8883b2022-03-28 20:47:102022-04-30 05:21:57

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 05:21:57]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-03-28 20:47:10]
  • 提交

answer

import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Solution
{
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		ArrayList<String> lines = new ArrayList<String>();
		ArrayList<Integer> sums = new ArrayList<Integer>();
		while(line!=null) {
			line = reader.readLine();
		}
		int players = Integer.parseInt(lines.get(0));
		for(int i=0; i<players; i++) {
			int sum = 0;
			for(String s: lines.get(i).split(" ")) {
				sum += Integer.parseInt(s);
			}
			sums.add(sum);
		}
		Collections.sort(sums);
		int max = 0;
		int min = 0;
		for(int i=0; i<players/2; i++) {
			max += sums.get(players-i-1);
			min += sums.get(i);
		}
		System.out.println((max-min)/2);
	}
}

详细

Test #1:

score: 0
Runtime Error

input:

20
0 786505 911962 -800624 363821 -960995 -492637 -246590 140762 54707 -353306 -82216 -175650 567363 113374 761152 906126 -394096 -635055 675627
786505 0 801116 -323471 -34197 -860051 865281 737621 307515 -493253 -128788 -171663 -21931 853897 -505337 72985 941995 -380960 -223577 265322
911962 801116...

output:


result: