結果

問題 No.178 美しいWhitespace (1)
ユーザー YamaKasaYamaKasa
提出日時 2018-05-18 15:04:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 72,764 KB
実行使用メモリ 60,672 KB
最終ジャッジ日時 2023-09-10 22:52:20
合計ジャッジ時間 8,558 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,996 KB
testcase_01 AC 124 ms
55,964 KB
testcase_02 AC 123 ms
55,780 KB
testcase_03 AC 124 ms
56,392 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 202 ms
58,116 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 201 ms
58,468 KB
testcase_12 AC 201 ms
59,020 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 197 ms
58,372 KB
testcase_19 WA -
testcase_20 AC 199 ms
58,416 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 197 ms
58,680 KB
testcase_24 AC 197 ms
58,388 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];
		int 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