結果
問題 |
No.185 和風
|
ユーザー |
|
提出日時 | 2019-02-13 18:50:56 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 207 ms / 1,000 ms |
コード長 | 426 bytes |
コンパイル時間 | 2,314 ms |
コンパイル使用メモリ | 76,204 KB |
実行使用メモリ | 56,580 KB |
最終ジャッジ日時 | 2024-09-13 11:11:09 |
合計ジャッジ時間 | 4,115 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
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()); } }