結果

問題 No.178 美しいWhitespace (1)
ユーザー kohaku_kohaku
提出日時 2016-11-13 08:13:59
言語 Java
(openjdk 23)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 73,752 KB
実行使用メモリ 56,856 KB
最終ジャッジ日時 2024-11-25 21:53:24
合計ジャッジ時間 8,297 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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