結果

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

ソースコード

diff #

import java.util.*;


public class Main {
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] space = new int[n];
		int max=0;
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			max=Math.max(max, a+b*4);
			space[i]=a+b*4;
		}
		long ans=0;
		for(int i=0;i<n;i++){
			if( (max-space[i])%2!=0){
				System.out.println(-1);
				return;
			}else{
				ans+=(max-space[i])/2;
			}
		}
		System.out.println(ans);
	}
}
0