結果

問題 No.178 美しいWhitespace (1)
ユーザー samplelpmassamplelpmas
提出日時 2016-11-15 13:09:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 1,859 ms
コンパイル使用メモリ 71,444 KB
実行使用メモリ 60,700 KB
最終ジャッジ日時 2023-08-17 06:57:37
合計ジャッジ時間 7,269 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,952 KB
testcase_01 AC 110 ms
55,716 KB
testcase_02 AC 111 ms
55,860 KB
testcase_03 AC 109 ms
56,172 KB
testcase_04 AC 183 ms
58,576 KB
testcase_05 AC 185 ms
58,184 KB
testcase_06 AC 185 ms
60,700 KB
testcase_07 AC 187 ms
57,928 KB
testcase_08 AC 182 ms
58,176 KB
testcase_09 AC 186 ms
58,568 KB
testcase_10 AC 186 ms
58,952 KB
testcase_11 AC 186 ms
58,836 KB
testcase_12 AC 184 ms
57,836 KB
testcase_13 AC 190 ms
58,528 KB
testcase_14 AC 183 ms
58,732 KB
testcase_15 AC 187 ms
58,884 KB
testcase_16 AC 184 ms
58,188 KB
testcase_17 AC 188 ms
58,788 KB
testcase_18 AC 183 ms
56,972 KB
testcase_19 AC 186 ms
58,008 KB
testcase_20 AC 186 ms
58,160 KB
testcase_21 AC 185 ms
58,112 KB
testcase_22 AC 184 ms
58,164 KB
testcase_23 AC 186 ms
58,872 KB
testcase_24 AC 188 ms
58,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int lines = sc.nextInt();

        int[] spaces = new int[lines];

        int max = 0;

        for (int i = 0; i < lines; i++) {

            int space = sc.nextInt();
            int tab = sc.nextInt();

            spaces[i] = space + (4 * tab);

            max = Math.max(max, spaces[i]);

        }

        long ideographicSpaces = 0;

        for (int i = 0; i < lines; i++) {

            int requiredSpaces = max - spaces[i];

            if (requiredSpaces % 2 == 1) {
                System.out.println(-1);
                return;
            }

            ideographicSpaces += requiredSpaces / 2;

        }

        System.out.println(ideographicSpaces);

    }

}
0