結果

問題 No.178 美しいWhitespace (1)
ユーザー chiho_miyako
提出日時 2015-04-06 00:20:55
言語 Java
(openjdk 23)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 74,292 KB
実行使用メモリ 56,880 KB
最終ジャッジ日時 2024-07-04 02:23:24
合計ジャッジ時間 7,633 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner (System.in);
        int n = koko.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i =0; i<n; i++){
            a[i] = koko.nextInt();
            b[i] = koko.nextInt();
        }
        int max=0;
        int[] white = new int[n];
        for(int i =0; i<n; i++){
            white[i] = a[i]+4*b[i];
            max = Math.max(max,white[i]);
        }
        long need=0;
        for(int i=0; i<n; i++){
            if((max-white[i])%2==0){
            need = need + (max-white[i])/2;
            }else{
                need = -1;
                break;
            }
        }
        System.out.println(need);

    }
}
0