結果

問題 No.178 美しいWhitespace (1)
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-30 10:32:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,193 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 74,468 KB
実行使用メモリ 51,560 KB
最終ジャッジ日時 2023-10-11 23:31:55
合計ジャッジ時間 5,400 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
46,948 KB
testcase_01 AC 44 ms
49,124 KB
testcase_02 AC 44 ms
49,100 KB
testcase_03 AC 44 ms
49,164 KB
testcase_04 AC 70 ms
51,240 KB
testcase_05 AC 69 ms
51,344 KB
testcase_06 AC 78 ms
50,088 KB
testcase_07 AC 79 ms
50,388 KB
testcase_08 AC 80 ms
51,560 KB
testcase_09 AC 70 ms
49,420 KB
testcase_10 AC 78 ms
51,468 KB
testcase_11 AC 68 ms
51,504 KB
testcase_12 AC 68 ms
51,428 KB
testcase_13 AC 80 ms
51,144 KB
testcase_14 AC 81 ms
50,384 KB
testcase_15 AC 69 ms
51,556 KB
testcase_16 AC 69 ms
51,364 KB
testcase_17 AC 71 ms
51,356 KB
testcase_18 AC 78 ms
51,160 KB
testcase_19 AC 70 ms
49,540 KB
testcase_20 AC 67 ms
50,900 KB
testcase_21 AC 68 ms
51,380 KB
testcase_22 AC 63 ms
50,452 KB
testcase_23 AC 69 ms
49,748 KB
testcase_24 AC 77 ms
51,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        String[] inputs;
        long max = Long.MIN_VALUE;
        long[] widths = new long[N];
        for (int i = 0; i < N; i++) {
            inputs = reader.readLine().split(" ");
            long a = Long.parseLong(inputs[0]);
            long b = Long.parseLong(inputs[1]);
            widths[i] = a + 4 * b;
            max = Math.max(max, a + 4 * b);
        }
        long numOfSpaces = 0;
        boolean isPerfect = true;
        for (int i = 0; i < N; i++) {
            if ((max - widths[i]) % 2 != 0) {
                isPerfect = false;
                break;
            } else {
                numOfSpaces += (max - widths[i]) / 2;

            }

        }

        if (isPerfect) {
            System.out.println(numOfSpaces);
        } else {
            System.out.println(-1);
        }

    }
}

0