結果

問題 No.178 美しいWhitespace (1)
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-05 21:06:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 74,912 KB
実行使用メモリ 60,460 KB
最終ジャッジ日時 2023-10-21 19:20:33
合計ジャッジ時間 7,626 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
57,412 KB
testcase_01 AC 127 ms
57,380 KB
testcase_02 AC 117 ms
56,224 KB
testcase_03 AC 125 ms
57,520 KB
testcase_04 AC 197 ms
59,904 KB
testcase_05 AC 200 ms
59,628 KB
testcase_06 AC 199 ms
59,808 KB
testcase_07 AC 190 ms
60,088 KB
testcase_08 AC 200 ms
59,712 KB
testcase_09 AC 199 ms
60,380 KB
testcase_10 AC 200 ms
59,812 KB
testcase_11 AC 193 ms
60,028 KB
testcase_12 AC 195 ms
59,708 KB
testcase_13 AC 192 ms
59,856 KB
testcase_14 AC 194 ms
59,692 KB
testcase_15 AC 193 ms
60,108 KB
testcase_16 AC 203 ms
59,892 KB
testcase_17 AC 189 ms
59,700 KB
testcase_18 AC 191 ms
59,700 KB
testcase_19 AC 201 ms
60,128 KB
testcase_20 AC 203 ms
59,828 KB
testcase_21 AC 195 ms
59,736 KB
testcase_22 AC 197 ms
60,460 KB
testcase_23 AC 196 ms
59,672 KB
testcase_24 AC 195 ms
59,600 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();

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

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

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