結果

問題 No.178 美しいWhitespace (1)
ユーザー YamaKasaYamaKasa
提出日時 2018-05-18 15:06:21
言語 Java19
(openjdk 21)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 71,748 KB
実行使用メモリ 60,308 KB
最終ジャッジ日時 2023-09-10 22:52:31
合計ジャッジ時間 8,064 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,132 KB
testcase_01 AC 126 ms
55,828 KB
testcase_02 AC 127 ms
56,172 KB
testcase_03 AC 128 ms
56,016 KB
testcase_04 AC 200 ms
58,908 KB
testcase_05 AC 200 ms
58,340 KB
testcase_06 AC 200 ms
58,828 KB
testcase_07 AC 199 ms
58,372 KB
testcase_08 AC 201 ms
58,632 KB
testcase_09 AC 199 ms
58,952 KB
testcase_10 AC 200 ms
60,308 KB
testcase_11 AC 201 ms
58,428 KB
testcase_12 AC 193 ms
58,668 KB
testcase_13 AC 201 ms
58,956 KB
testcase_14 AC 201 ms
58,900 KB
testcase_15 AC 197 ms
58,740 KB
testcase_16 AC 198 ms
58,140 KB
testcase_17 AC 195 ms
58,356 KB
testcase_18 AC 198 ms
57,776 KB
testcase_19 AC 201 ms
58,792 KB
testcase_20 AC 202 ms
58,632 KB
testcase_21 AC 201 ms
58,484 KB
testcase_22 AC 192 ms
57,816 KB
testcase_23 AC 194 ms
58,764 KB
testcase_24 AC 195 ms
58,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []l = new int[N];
		for(int i = 0; i < N; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			l[i] = a + 4 * b;
		}
		scan.close();
		Arrays.sort(l);
		int max = l[N - 1];
		long c = 0;
		for(int i = 0; i < N - 1; i++) {
			if((max - l[i]) % 2 == 1) {
				System.out.println(-1);
				System.exit(0);
			}else {
				c += (max - l[i]) / 2;
			}
		}
		System.out.println(c);
	}
}
0