結果

問題 No.185 和風
コンテスト
ユーザー はまやんはまやん
提出日時 2015-06-24 23:35:54
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 114 ms / 1,000 ms
コード長 734 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,722 ms
コンパイル使用メモリ 83,304 KB
実行使用メモリ 46,764 KB
最終ジャッジ日時 2026-03-29 08:34:25
合計ジャッジ時間 2,997 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.HashSet;
import java.util.Scanner;


public class Main {
	static int N;
	static int[] X, Y;
			
	static private void solve()
	{
		HashSet<Integer> hs = new HashSet<Integer>();
		
		for (int i = 0; i < N; i++) {
			hs.add(new Integer(Y[i] - X[i]));
		}
		
		if (hs.size() > 1) {
			System.out.println("-1");
			return;
		}
		
		for (Integer i : hs) {
			if(i.intValue() <= 0)
			{
				System.out.println("-1");
				return;
			}
			
			System.out.println(i);
		}
	}
	
	static public void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		
		N = sca.nextInt();
		
		X = new int[N];
		Y = new int[N];
		for (int i = 0; i < N; i++) {
			X[i] = sca.nextInt();
			Y[i] = sca.nextInt();
		}
		
		solve();
	}
}
0