結果
問題 | No.185 和風 |
ユーザー | YOSHI |
提出日時 | 2021-03-03 21:38:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 77 ms / 1,000 ms |
コード長 | 779 bytes |
コンパイル時間 | 3,495 ms |
コンパイル使用メモリ | 74,456 KB |
実行使用メモリ | 51,216 KB |
最終ジャッジ日時 | 2024-04-14 13:18:07 |
合計ジャッジ時間 | 4,843 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
50,156 KB |
testcase_01 | AC | 77 ms
51,100 KB |
testcase_02 | AC | 54 ms
50,040 KB |
testcase_03 | AC | 53 ms
50,252 KB |
testcase_04 | AC | 53 ms
50,268 KB |
testcase_05 | AC | 53 ms
50,292 KB |
testcase_06 | AC | 76 ms
51,216 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No00000185_Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] strArr = br.readLine().split(" "); int x = Integer.parseInt(strArr[0]); int y = Integer.parseInt(strArr[1]); int ans = y - x; if(ans <= 0) { System.out.println(-1); return; } n--; boolean flg = true; while(n > 0) { strArr = br.readLine().split(" "); x = Integer.parseInt(strArr[0]); y = Integer.parseInt(strArr[1]); if(ans != y - x) { flg = false; break; } n--; } System.out.println(flg ? ans : -1); } }