結果

問題 No.178 美しいWhitespace (1)
ユーザー ffmm00ffmm00
提出日時 2015-06-04 17:18:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 3,567 ms
コンパイル使用メモリ 72,748 KB
実行使用メモリ 58,136 KB
最終ジャッジ日時 2023-09-20 19:09:03
合計ジャッジ時間 9,566 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,796 KB
testcase_01 AC 127 ms
55,596 KB
testcase_02 AC 128 ms
55,668 KB
testcase_03 AC 129 ms
55,700 KB
testcase_04 AC 203 ms
58,136 KB
testcase_05 AC 200 ms
43,068 KB
testcase_06 AC 201 ms
42,476 KB
testcase_07 AC 202 ms
41,852 KB
testcase_08 AC 202 ms
42,004 KB
testcase_09 AC 204 ms
41,404 KB
testcase_10 AC 208 ms
41,916 KB
testcase_11 AC 207 ms
41,328 KB
testcase_12 AC 196 ms
42,412 KB
testcase_13 AC 201 ms
41,200 KB
testcase_14 AC 200 ms
41,448 KB
testcase_15 AC 202 ms
41,888 KB
testcase_16 AC 203 ms
41,728 KB
testcase_17 AC 202 ms
42,252 KB
testcase_18 AC 206 ms
42,052 KB
testcase_19 AC 207 ms
41,468 KB
testcase_20 AC 197 ms
41,596 KB
testcase_21 AC 199 ms
42,488 KB
testcase_22 AC 198 ms
42,060 KB
testcase_23 AC 200 ms
41,636 KB
testcase_24 AC 199 ms
41,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N178 {

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

		int n = sca.nextInt();
		long 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 ; i++) {
			if ((max - d[i]) % 2 != 0) {
				System.out.println(-1);
				return;
			} else
				c += (max - d[i]) / 2;
		}

		System.out.println(c);

	}

}
0