結果

問題 No.178 美しいWhitespace (1)
ユーザー Flere0114Flere0114
提出日時 2016-02-24 12:38:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 738 bytes
コンパイル時間 3,458 ms
コンパイル使用メモリ 74,812 KB
実行使用メモリ 58,044 KB
最終ジャッジ日時 2023-10-23 19:34:06
合計ジャッジ時間 8,849 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
57,108 KB
testcase_01 AC 112 ms
56,192 KB
testcase_02 AC 122 ms
57,472 KB
testcase_03 AC 123 ms
57,512 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 173 ms
57,612 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 168 ms
57,808 KB
testcase_12 AC 172 ms
57,820 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 174 ms
57,464 KB
testcase_19 WA -
testcase_20 AC 174 ms
57,716 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 163 ms
57,796 KB
testcase_24 AC 178 ms
57,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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

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

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

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