結果
問題 | No.185 和風 |
ユーザー | Tsukasa_Type |
提出日時 | 2018-02-09 18:13:27 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 206 ms / 1,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 2,176 ms |
コンパイル使用メモリ | 74,448 KB |
実行使用メモリ | 44,008 KB |
最終ジャッジ日時 | 2024-04-16 19:08:59 |
合計ジャッジ時間 | 4,147 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 191 ms
42,352 KB |
testcase_01 | AC | 202 ms
43,340 KB |
testcase_02 | AC | 203 ms
43,600 KB |
testcase_03 | AC | 203 ms
44,008 KB |
testcase_04 | AC | 206 ms
43,992 KB |
testcase_05 | AC | 148 ms
41,560 KB |
testcase_06 | AC | 196 ms
43,948 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]);} } } }