結果

問題 No.178 美しいWhitespace (1)
ユーザー ffmm00ffmm00
提出日時 2015-06-04 17:15:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 535 bytes
コンパイル時間 3,331 ms
コンパイル使用メモリ 72,284 KB
実行使用メモリ 60,152 KB
最終ジャッジ日時 2023-09-20 19:08:52
合計ジャッジ時間 8,947 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 122 ms
55,764 KB
testcase_02 AC 122 ms
56,036 KB
testcase_03 AC 122 ms
55,640 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 196 ms
58,600 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 195 ms
58,884 KB
testcase_12 AC 198 ms
58,584 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 195 ms
58,004 KB
testcase_19 WA -
testcase_20 AC 195 ms
58,936 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 194 ms
56,280 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N178 {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);

		int n = sca.nextInt();
		int c = 0;
		int[] d = new int[n];
		int max = 0;

		for (int i = 0; i < n; i++) {
			int a = sca.nextInt();
			int b = sca.nextInt();
			max = Math.max(max, a + b * 4);
			d[i] = a + 4 * b;
		}

		for (int i = 0; i < n - 1; i++) {
			if ((max - d[i]) % 2 != 0) {
				System.out.println(-1);
				return;
			} else
				c += (max - d[i]) / 2;
		}

		System.out.println(c);

	}

}
0