結果

問題 No.178 美しいWhitespace (1)
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-04-05 23:26:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,075 bytes
コンパイル時間 3,113 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 60,912 KB
最終ジャッジ日時 2023-09-17 04:39:05
合計ジャッジ時間 8,226 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,568 KB
testcase_01 AC 111 ms
55,676 KB
testcase_02 AC 109 ms
55,956 KB
testcase_03 AC 105 ms
55,900 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 181 ms
58,328 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 179 ms
58,260 KB
testcase_12 AC 163 ms
58,448 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 172 ms
58,724 KB
testcase_19 WA -
testcase_20 AC 168 ms
58,768 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 178 ms
58,344 KB
testcase_24 AC 161 ms
58,456 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();
        int[] a = new int[n];
        int max = 0;
        for (int i=0; i<n; i++) {
            a[i] = in.nextInt()+in.nextInt()*4;
            max = max(max,a[i]);
        }
        int 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