結果

問題 No.178 美しいWhitespace (1)
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-05 21:04:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 74,108 KB
実行使用メモリ 60,524 KB
最終ジャッジ日時 2023-10-21 19:20:24
合計ジャッジ時間 7,799 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
57,076 KB
testcase_01 AC 134 ms
57,468 KB
testcase_02 AC 131 ms
57,452 KB
testcase_03 AC 132 ms
57,372 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 203 ms
59,632 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 203 ms
60,336 KB
testcase_12 AC 199 ms
59,760 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 207 ms
59,756 KB
testcase_19 WA -
testcase_20 AC 204 ms
59,880 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 202 ms
59,508 KB
testcase_24 AC 204 ms
59,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Test {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();

		int[] w = new int[n];
		int max = 0;
		boolean bool = true;

		for(int i=0; i<n; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			w[i] = a + b * 4;
			max = Math.max(max, w[i]);
			if(i > 0 && w[i] % 2 != w[i-1] % 2) {
				bool = false;
			}
		}

		if(bool) {
			int ans = 0;
			for(int i=0; i<n; i++) {
				ans += (max - w[i]) / 2;
			}
			System.out.println(ans);
		} else {
			System.out.println(-1);
		}
	}
}
0