結果
問題 |
No.185 和風
|
ユーザー |
![]() |
提出日時 | 2016-05-22 18:46:49 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 572 bytes |
コンパイル時間 | 2,098 ms |
コンパイル使用メモリ | 75,592 KB |
実行使用メモリ | 56,764 KB |
最終ジャッジ日時 | 2024-10-06 20:36:24 |
合計ジャッジ時間 | 4,282 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 2 |
ソースコード
import java.util.*; class No0185{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long result = 0; ArrayList<Long> x = new ArrayList<Long>(); for(int i = 0; i < n; i++){ x.add(sc.nextLong()); x.set(i, (sc.nextLong() - x.get(i))); } for(int i = 0; i < n; i++){ if(x.get(i) < 0){ result = -1; break; } if(x.get(i) != x.get(i + 1)){ result = -1; break; } if(i == n - 2){ break; } } if(result != -1) result = x.get(0); System.out.println(result); } }