結果

問題 No.178 美しいWhitespace (1)
ユーザー GrenacheGrenache
提出日時 2015-11-03 11:44:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 802 bytes
コンパイル時間 3,840 ms
コンパイル使用メモリ 72,596 KB
実行使用メモリ 59,352 KB
最終ジャッジ日時 2023-10-11 13:17:31
合計ジャッジ時間 9,341 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,336 KB
testcase_01 AC 124 ms
55,828 KB
testcase_02 AC 127 ms
55,956 KB
testcase_03 AC 126 ms
55,584 KB
testcase_04 AC 197 ms
58,448 KB
testcase_05 AC 196 ms
58,848 KB
testcase_06 AC 198 ms
59,028 KB
testcase_07 AC 198 ms
56,700 KB
testcase_08 AC 196 ms
58,144 KB
testcase_09 AC 194 ms
58,352 KB
testcase_10 AC 196 ms
58,296 KB
testcase_11 AC 196 ms
56,960 KB
testcase_12 AC 200 ms
59,352 KB
testcase_13 AC 197 ms
58,076 KB
testcase_14 AC 199 ms
58,188 KB
testcase_15 AC 199 ms
58,296 KB
testcase_16 AC 198 ms
58,204 KB
testcase_17 AC 198 ms
58,712 KB
testcase_18 AC 196 ms
58,568 KB
testcase_19 AC 198 ms
58,192 KB
testcase_20 AC 188 ms
58,508 KB
testcase_21 AC 200 ms
58,188 KB
testcase_22 AC 194 ms
59,148 KB
testcase_23 AC 198 ms
58,476 KB
testcase_24 AC 198 ms
58,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder178 {

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

        int n = sc.nextInt();
        long[] s = new long[n];
        long max = 0;
        boolean flag = true;
        for (int i = 0; i < n; i++) {
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	s[i] = (long)a + b * 4;
        	max = Math.max(max, s[i]);
        	if (i > 0 && s[i] % 2 != s[i - 1] % 2) {
        		flag = false;
        	}
        }

        if (flag) {
        	long ret = 0;
        	for (int i = 0; i < n; i++) {
        		ret += (max - s[i]) / 2;
        	}
        	
        	System.out.println(ret);
        } else {
        	System.out.println("-1");
        }
        
        sc.close();
    }
}
0