結果

問題 No.178 美しいWhitespace (1)
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-04-05 23:35:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 1,088 bytes
コンパイル時間 3,402 ms
コンパイル使用メモリ 74,976 KB
実行使用メモリ 58,840 KB
最終ジャッジ日時 2023-09-17 04:43:22
合計ジャッジ時間 9,084 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,540 KB
testcase_01 AC 125 ms
55,804 KB
testcase_02 AC 122 ms
56,048 KB
testcase_03 AC 125 ms
55,716 KB
testcase_04 AC 201 ms
58,400 KB
testcase_05 AC 192 ms
58,768 KB
testcase_06 AC 199 ms
58,552 KB
testcase_07 AC 199 ms
58,388 KB
testcase_08 AC 199 ms
58,152 KB
testcase_09 AC 198 ms
57,904 KB
testcase_10 AC 201 ms
58,028 KB
testcase_11 AC 200 ms
58,448 KB
testcase_12 AC 196 ms
58,556 KB
testcase_13 AC 198 ms
58,416 KB
testcase_14 AC 196 ms
58,612 KB
testcase_15 AC 197 ms
56,648 KB
testcase_16 AC 188 ms
58,260 KB
testcase_17 AC 198 ms
58,260 KB
testcase_18 AC 197 ms
57,752 KB
testcase_19 AC 199 ms
58,016 KB
testcase_20 AC 201 ms
58,840 KB
testcase_21 AC 199 ms
58,444 KB
testcase_22 AC 193 ms
58,300 KB
testcase_23 AC 201 ms
58,056 KB
testcase_24 AC 202 ms
58,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No178 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int n = in.nextInt();
        long[] a = new long[n];
        long max = 0;
        for (int i=0; i<n; i++) {
            a[i] = in.nextInt()+in.nextInt()*4;
            max = max(max,a[i]);
        }
        
        long cnt = 0;
        for (int i=0; i<n; i++) {
            if ((max - a[i]) %2 == 1) {
                out.println("-1");
                return ;
            }
            cnt += (max - a[i])/2;
        }
        out.println(cnt);
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        in.close();
        out.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0