結果

問題 No.178 美しいWhitespace (1)
ユーザー t8m8⛄️
提出日時 2015-04-05 23:26:14
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,075 bytes
コンパイル時間 3,110 ms
コンパイル使用メモリ 78,120 KB
実行使用メモリ 43,760 KB
最終ジャッジ日時 2024-07-04 02:09:29
合計ジャッジ時間 8,383 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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