結果

問題 No.178 美しいWhitespace (1)
ユーザー dazydazy
提出日時 2017-02-22 16:58:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 3,979 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 58,988 KB
最終ジャッジ日時 2023-08-29 01:21:41
合計ジャッジ時間 9,653 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,356 KB
testcase_01 AC 119 ms
56,316 KB
testcase_02 AC 118 ms
55,824 KB
testcase_03 AC 121 ms
55,996 KB
testcase_04 AC 186 ms
58,444 KB
testcase_05 AC 185 ms
58,340 KB
testcase_06 AC 185 ms
58,324 KB
testcase_07 AC 113 ms
56,448 KB
testcase_08 AC 192 ms
58,340 KB
testcase_09 AC 190 ms
58,132 KB
testcase_10 AC 188 ms
58,664 KB
testcase_11 AC 119 ms
55,916 KB
testcase_12 AC 121 ms
56,092 KB
testcase_13 AC 193 ms
58,784 KB
testcase_14 AC 191 ms
58,400 KB
testcase_15 AC 191 ms
58,988 KB
testcase_16 AC 195 ms
58,596 KB
testcase_17 AC 191 ms
58,536 KB
testcase_18 AC 120 ms
56,056 KB
testcase_19 AC 191 ms
58,604 KB
testcase_20 AC 115 ms
56,396 KB
testcase_21 AC 193 ms
56,432 KB
testcase_22 AC 184 ms
58,248 KB
testcase_23 AC 192 ms
56,896 KB
testcase_24 AC 190 ms
58,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int [] a = new int[N];
        int [] b = new int[N];
        long [] c = new long[N];
        long ans = 0;
        long max = 0;
        int num = 0;
        boolean x = false, y = false;

        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();

            if (a[i]%2==0) x = true;
            else y = true;
            if (x && y) break;

            c[i] = a[i] + 4*b[i];
            if (max < c[i]) {
                num = i;
                max = c[i];
            }
        }

        for (int i = 0; i < N; i++) {
            if (x && y) {
                ans = -1;
                break;
            }
            ans += (c[num] - c[i])/2;
        }

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