結果

問題 No.178 美しいWhitespace (1)
ユーザー Flere0114Flere0114
提出日時 2016-02-24 12:41:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 3,200 ms
コンパイル使用メモリ 74,696 KB
実行使用メモリ 57,972 KB
最終ジャッジ日時 2023-10-23 19:34:25
合計ジャッジ時間 8,320 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
57,172 KB
testcase_01 AC 109 ms
56,160 KB
testcase_02 AC 120 ms
57,380 KB
testcase_03 AC 120 ms
57,312 KB
testcase_04 AC 180 ms
57,972 KB
testcase_05 AC 175 ms
57,648 KB
testcase_06 AC 173 ms
57,864 KB
testcase_07 AC 169 ms
57,808 KB
testcase_08 AC 181 ms
57,780 KB
testcase_09 AC 178 ms
57,828 KB
testcase_10 AC 170 ms
57,672 KB
testcase_11 AC 183 ms
57,692 KB
testcase_12 AC 173 ms
57,888 KB
testcase_13 AC 173 ms
57,852 KB
testcase_14 AC 177 ms
57,760 KB
testcase_15 AC 174 ms
57,812 KB
testcase_16 AC 176 ms
57,784 KB
testcase_17 AC 180 ms
57,676 KB
testcase_18 AC 173 ms
57,760 KB
testcase_19 AC 174 ms
57,816 KB
testcase_20 AC 172 ms
57,740 KB
testcase_21 AC 182 ms
57,752 KB
testcase_22 AC 173 ms
57,580 KB
testcase_23 AC 174 ms
57,532 KB
testcase_24 AC 178 ms
57,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No178 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long max = 0, ans = 0;
        int N;
        N = Integer.parseInt(sc.next());
        long[] a = new long[N];
        long[] b = new long[N];

        for (int i = 0; i < N; i++) {
            a[i] = Long.parseLong(sc.next());
            b[i] = Long.parseLong(sc.next());
            max = Math.max(max, a[i] + 4 * b[i]);
        }

        for (int i = 0; i < N; i++) {
            long po = max - (a[i] + 4 * b[i]);
            if(po % 2 == 1){
                System.out.println(-1);
                return;
            }
            ans += po / 2;
        }

        System.out.println(ans);
    }
}
0