結果

問題 No.185 和風
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2015-06-24 23:35:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 207 ms / 1,000 ms
コード長 734 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 72,312 KB
実行使用メモリ 58,760 KB
最終ジャッジ日時 2023-09-22 00:35:23
合計ジャッジ時間 4,358 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
54,128 KB
testcase_01 AC 204 ms
58,520 KB
testcase_02 AC 207 ms
58,760 KB
testcase_03 AC 204 ms
58,456 KB
testcase_04 AC 207 ms
58,072 KB
testcase_05 AC 149 ms
55,816 KB
testcase_06 AC 201 ms
58,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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