結果

問題 No.178 美しいWhitespace (1)
ユーザー samplelpmassamplelpmas
提出日時 2016-11-15 13:06:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 74,276 KB
実行使用メモリ 43,864 KB
最終ジャッジ日時 2024-05-04 13:51:20
合計ジャッジ時間 8,141 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 131 ms
41,460 KB
testcase_02 WA -
testcase_03 AC 133 ms
41,260 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 205 ms
43,776 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 206 ms
43,444 KB
testcase_12 AC 201 ms
43,100 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 206 ms
43,368 KB
testcase_19 WA -
testcase_20 AC 207 ms
43,572 KB
testcase_21 WA -
testcase_22 AC 193 ms
43,424 KB
testcase_23 AC 204 ms
43,484 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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 tab = sc.nextInt();
            int space = 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