結果

問題 No.178 美しいWhitespace (1)
ユーザー mits58
提出日時 2016-07-02 15:19:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 2,396 ms
コンパイル使用メモリ 77,404 KB
実行使用メモリ 43,516 KB
最終ジャッジ日時 2024-10-12 00:53:31
合計ジャッジ時間 8,149 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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