結果
問題 |
No.185 和風
|
ユーザー |
|
提出日時 | 2025-09-21 17:42:45 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 211 ms / 1,000 ms |
コード長 | 791 bytes |
コンパイル時間 | 6,923 ms |
コンパイル使用メモリ | 78,324 KB |
実行使用メモリ | 51,016 KB |
最終ジャッジ日時 | 2025-09-21 17:42:54 |
合計ジャッジ時間 | 5,139 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { a[i] = scanner.nextInt(); b[i] = scanner.nextInt(); } int result = -1; List<Integer> vec = new ArrayList<>(); for (int i = 0; i < n; i++) { vec.add(b[i] - a[i]); } Collections.sort(vec); int first = vec.get(0); int last = vec.get(vec.size() - 1); if (first == last && last > 0) { result = last; } System.out.println(result); } }