結果

問題 No.185 和風
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-13 18:49:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 74,376 KB
実行使用メモリ 58,568 KB
最終ジャッジ日時 2023-10-11 12:23:07
合計ジャッジ時間 4,564 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
56,096 KB
testcase_01 AC 196 ms
58,252 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 196 ms
58,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		for (int i=0; i<n; i++) {
			int a = sc.nextInt(); int b = sc.nextInt();
			if (b-a < 1) {
				System.out.println(1); return;
			}
			set.add(b-a);
		}
		
		System.out.println(set.size()>=2?-1:set.stream().findFirst().get());
		
	}
}
0