結果

問題 No.178 美しいWhitespace (1)
ユーザー ぴろずぴろず
提出日時 2015-03-07 13:00:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 680 bytes
コンパイル時間 4,101 ms
コンパイル使用メモリ 71,956 KB
実行使用メモリ 58,700 KB
最終ジャッジ日時 2023-09-06 20:55:42
合計ジャッジ時間 8,642 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,560 KB
testcase_01 AC 123 ms
55,972 KB
testcase_02 AC 121 ms
55,668 KB
testcase_03 AC 120 ms
55,752 KB
testcase_04 AC 193 ms
58,044 KB
testcase_05 AC 194 ms
58,576 KB
testcase_06 AC 197 ms
58,488 KB
testcase_07 AC 205 ms
58,404 KB
testcase_08 AC 192 ms
58,616 KB
testcase_09 AC 194 ms
58,480 KB
testcase_10 AC 194 ms
58,044 KB
testcase_11 AC 194 ms
57,972 KB
testcase_12 AC 195 ms
58,160 KB
testcase_13 AC 187 ms
58,528 KB
testcase_14 AC 196 ms
58,220 KB
testcase_15 AC 196 ms
58,700 KB
testcase_16 AC 195 ms
58,208 KB
testcase_17 AC 197 ms
58,252 KB
testcase_18 AC 192 ms
57,708 KB
testcase_19 AC 196 ms
57,936 KB
testcase_20 AC 196 ms
58,436 KB
testcase_21 AC 196 ms
58,156 KB
testcase_22 AC 192 ms
58,408 KB
testcase_23 AC 197 ms
58,156 KB
testcase_24 AC 200 ms
58,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package perfectws;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		assert 2 <= n && n <= 1000;
		long max = 0;
		long sum = 0;
		boolean odd = false;
		boolean even = false;
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			assert 0 <= a && a <= 10000000 && 0 <= b && b <= 10000000;
			int width = a + b * 4;
			max = Math.max(max, width);
			sum += width;
			if (width % 2 == 0) {
				even = true;
			}else{
				odd = true;
			}
		}
		if (odd && even) {
			System.out.println(-1);
		}else{
			System.out.println((max * n - sum) / 2);
		}

	}
}
0