結果
| 問題 | No.185 和風 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-21 17:42:45 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 1,000 ms |
| + 554µs | |
| コード長 | 791 bytes |
| 記録 | |
| コンパイル時間 | 1,380 ms |
| コンパイル使用メモリ | 86,428 KB |
| 実行使用メモリ | 48,220 KB |
| 最終ジャッジ日時 | 2026-07-15 04:30:34 |
| 合計ジャッジ時間 | 3,068 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
}
}