結果
問題 | No.185 和風 |
ユーザー |
![]() |
提出日時 | 2017-10-15 17:27:21 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 216 ms / 1,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 2,144 ms |
コンパイル使用メモリ | 74,892 KB |
実行使用メモリ | 56,824 KB |
最終ジャッジ日時 | 2024-11-17 17:53:03 |
合計ジャッジ時間 | 4,116 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; for(int i = 0 ; i < n ; i++) { x[i] =sc.nextInt(); y[i] = sc.nextInt(); } long[] a = new long[n]; for(int i = 0 ; i < n ; i++) { a[i] = y[i] - x[i]; } for(int i = 0 ; i < n ; i++) { for(int j = i + 1 ; j < n ; j++) { if(a[i] != a[j] || a[i] <= 0) { System.out.println(-1); return; } } } System.out.println(a[0]); } }