結果

問題 No.185 和風
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-22 15:43:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 185 ms / 1,000 ms
コード長 450 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 74,504 KB
実行使用メモリ 57,116 KB
最終ジャッジ日時 2024-04-10 10:28:12
合計ジャッジ時間 3,578 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
54,428 KB
testcase_01 AC 185 ms
57,116 KB
testcase_02 AC 122 ms
53,936 KB
testcase_03 AC 121 ms
53,956 KB
testcase_04 AC 180 ms
56,568 KB
testcase_05 AC 133 ms
54,144 KB
testcase_06 AC 176 ms
56,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x0 = sc.nextInt();
    int y0 = sc.nextInt();
    int ans = y0 - x0;
    for(int i = 1; i < N; i++) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      if(ans != y - x) {
        ans = -1;
        break;
      }
    }
    if(ans <= 0) ans = -1;
    System.out.println(ans);
  }
}
0