結果
問題 | No.185 和風 |
ユーザー |
![]() |
提出日時 | 2015-12-14 15:15:02 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 80 ms / 1,000 ms |
コード長 | 847 bytes |
コンパイル時間 | 2,084 ms |
コンパイル使用メモリ | 72,768 KB |
実行使用メモリ | 38,116 KB |
最終ジャッジ日時 | 2024-09-15 12:33:06 |
合計ジャッジ時間 | 2,968 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
package yukicoder; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); try { int N = Integer.parseInt(read.readLine()); int num; String[] box = read.readLine().split(" "); int x, y; x = Integer.parseInt(box[0]); y = Integer.parseInt(box[1]); num = y - x; if (num <= 0) { System.out.println(-1); return; } int i; for (i = 1; i < N; ++i) { box = read.readLine().split(" "); x = Integer.parseInt(box[0]); y = Integer.parseInt(box[1]); if (num != (y - x)) { break; } } if (i < N) { System.out.println(-1); } else { System.out.println(num); } } catch (Exception e) { e.printStackTrace(); } } }