結果
問題 |
No.185 和風
|
ユーザー |
![]() |
提出日時 | 2016-05-18 00:14:38 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 690 bytes |
コンパイル時間 | 2,555 ms |
コンパイル使用メモリ | 75,280 KB |
実行使用メモリ | 43,544 KB |
最終ジャッジ日時 | 2024-10-06 05:22:46 |
合計ジャッジ時間 | 3,697 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 RE * 5 |
ソースコード
import java.util.*; class No0185{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int result = 0; ArrayList<Integer> x = new ArrayList<Integer>(); ArrayList<Integer> y = new ArrayList<Integer>(); ArrayList<Integer> z = new ArrayList<Integer>(); for(int i = 0; i < n; i++){ x.add(sc.nextInt()); x.set(i, (sc.nextInt() - x.get(i))); } for(int i = 0; i < n; i++){ if(x.get(i) < 0 || x.get(i - 1) < 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); } }