結果

問題 No.178 美しいWhitespace (1)
ユーザー ki_ki33
提出日時 2015-04-05 23:49:12
言語 Java
(openjdk 23)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 2,492 ms
コンパイル使用メモリ 85,776 KB
実行使用メモリ 43,804 KB
最終ジャッジ日時 2024-07-04 02:14:24
合計ジャッジ時間 7,173 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListSet;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;
	//static boolean MAP[][];
	static int N;
	static int B;
	static int[][] POS;
	static String S;
	static int X[][];
	static int HA[];
	static long DP[];
	static int ST[][];
	static ConcurrentSkipListSet<Integer> TS;
	static ArrayList<Integer> AL;
	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);

		N = sc.nextInt();
		long[] a = new long[N];
		long max = 0;
		for (int i =0; i < N; i++) {
			a[i] = sc.nextLong()*1 + sc.nextLong()*4;
			max = Math.max(max, a[i]);
		}
		
		
		long ans = 0;
		
		
		for (int i=0; i < N; i++) {
			long num = -a[i] + max;
			if (num %2 != 0) {
				ans = -1;
				break;
			}
			ans += num/2;
		}
		
		System.out.println(ans);
		
	}
}
0