結果
問題 | No.185 和風 |
ユーザー | Tsukasa_Type |
提出日時 | 2018-02-09 18:13:27 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 210 ms / 1,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 2,487 ms |
コンパイル使用メモリ | 71,852 KB |
実行使用メモリ | 58,904 KB |
最終ジャッジ日時 | 2023-07-29 13:04:51 |
合計ジャッジ時間 | 4,798 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 200 ms
56,188 KB |
testcase_01 | AC | 198 ms
58,452 KB |
testcase_02 | AC | 210 ms
58,580 KB |
testcase_03 | AC | 202 ms
58,904 KB |
testcase_04 | AC | 207 ms
58,868 KB |
testcase_05 | AC | 149 ms
55,668 KB |
testcase_06 | AC | 199 ms
58,400 KB |
ソースコード
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int[] ar = new int[n]; for (int i=0; i<n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); ar[i] = b - a; } boolean exist = true; for (int i=0; i<n-1; i++) { if (ar[i]!=ar[i+1]) {exist = false;} } if (exist==false) { System.out.println(-1); } else { if (ar[0]<=0) {System.out.println(-1);} else {System.out.println(ar[0]);} } } }