結果

問題 No.178 美しいWhitespace (1)
ユーザー TatsuDXTatsuDX
提出日時 2016-09-09 00:17:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 2,852 ms
コンパイル使用メモリ 74,264 KB
実行使用メモリ 57,016 KB
最終ジャッジ日時 2024-04-27 18:13:03
合計ジャッジ時間 7,839 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
52,564 KB
testcase_01 AC 107 ms
53,276 KB
testcase_02 AC 114 ms
54,052 KB
testcase_03 AC 105 ms
52,912 KB
testcase_04 AC 179 ms
56,516 KB
testcase_05 AC 177 ms
56,464 KB
testcase_06 AC 179 ms
56,660 KB
testcase_07 AC 179 ms
56,636 KB
testcase_08 AC 178 ms
57,016 KB
testcase_09 AC 170 ms
56,352 KB
testcase_10 AC 182 ms
56,304 KB
testcase_11 AC 172 ms
56,660 KB
testcase_12 AC 175 ms
56,448 KB
testcase_13 AC 176 ms
56,560 KB
testcase_14 AC 187 ms
56,392 KB
testcase_15 AC 182 ms
56,724 KB
testcase_16 AC 175 ms
56,192 KB
testcase_17 AC 179 ms
56,620 KB
testcase_18 AC 173 ms
56,560 KB
testcase_19 AC 172 ms
56,360 KB
testcase_20 AC 179 ms
56,768 KB
testcase_21 AC 176 ms
56,492 KB
testcase_22 AC 177 ms
56,616 KB
testcase_23 AC 174 ms
56,096 KB
testcase_24 AC 182 ms
56,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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

		long n = sc.nextLong(), sum = 0, max = 0, t;
		boolean a = false, b = false;
		for(int i = 0; i < n; i++){
			t = sc.nextLong() + sc.nextLong() * 4;
			if(t % 2 == 0){
				a = true;
			} else {
				b = true;
			}
			max = Math.max(max, t);
			sum += t;
		}
		if(a && b){
			System.out.println(-1);
			return;
		}
		System.out.println((max*n - sum)/2);
	}
}
0