結果
問題 | No.185 和風 |
ユーザー |
|
提出日時 | 2017-09-27 09:02:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 200 ms / 1,000 ms |
コード長 | 552 bytes |
コンパイル時間 | 3,743 ms |
コンパイル使用メモリ | 74,472 KB |
実行使用メモリ | 43,560 KB |
最終ジャッジ日時 | 2024-11-15 17:30:44 |
合計ジャッジ時間 | 5,848 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
import java.util.Scanner; public class No185 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] input = new int[N*2]; for (int i=0; i< N * 2; i++) input[i] = sc.nextInt(); int dif = input[1] - input[0]; int count = 0; if(dif <= 0) System.out.println("-1"); else{ for(int i=0; i < N * 2; i = i + 2){ if(input[i] + dif == input[i+1]) count++; } if(count ==N ) System.out.println(dif); else System.out.println("-1"); sc.close(); } } }