結果

問題 No.185 和風
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-13 18:50:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 1,000 ms
コード長 426 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 74,668 KB
実行使用メモリ 58,628 KB
最終ジャッジ日時 2023-10-11 12:23:19
合計ジャッジ時間 3,853 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
54,680 KB
testcase_01 AC 196 ms
58,248 KB
testcase_02 AC 121 ms
56,072 KB
testcase_03 AC 122 ms
56,268 KB
testcase_04 AC 120 ms
55,972 KB
testcase_05 AC 121 ms
56,008 KB
testcase_06 AC 195 ms
58,628 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