結果

問題 No.178 美しいWhitespace (1)
ユーザー kenkooookenkoooo
提出日時 2015-04-18 00:20:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 72,672 KB
実行使用メモリ 59,388 KB
最終ジャッジ日時 2023-09-17 22:15:20
合計ジャッジ時間 7,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,876 KB
testcase_01 AC 127 ms
56,040 KB
testcase_02 AC 124 ms
56,100 KB
testcase_03 AC 123 ms
55,808 KB
testcase_04 AC 196 ms
58,728 KB
testcase_05 AC 200 ms
59,180 KB
testcase_06 AC 198 ms
58,520 KB
testcase_07 AC 194 ms
58,716 KB
testcase_08 AC 196 ms
58,404 KB
testcase_09 AC 196 ms
58,804 KB
testcase_10 AC 198 ms
59,388 KB
testcase_11 AC 199 ms
57,988 KB
testcase_12 AC 194 ms
58,128 KB
testcase_13 AC 195 ms
58,340 KB
testcase_14 AC 197 ms
58,804 KB
testcase_15 AC 198 ms
58,568 KB
testcase_16 AC 198 ms
58,524 KB
testcase_17 AC 195 ms
58,492 KB
testcase_18 AC 193 ms
58,472 KB
testcase_19 AC 196 ms
57,964 KB
testcase_20 AC 195 ms
58,296 KB
testcase_21 AC 196 ms
59,124 KB
testcase_22 AC 191 ms
58,444 KB
testcase_23 AC 196 ms
58,080 KB
testcase_24 AC 198 ms
58,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		sc.close();

		int max = 0;
		for (int i = 0; i < N; i++) {
			max = Math.max(a[i] + 4 * b[i], max);
		}
		long c = 0;
		for (int i = 0; i < N; i++) {
			if ((max - a[i] - 4 * b[i]) % 2 == 0) {
				c += (max - a[i] - 4 * b[i]) / 2;
			} else {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(c);

	}
}
0