結果

問題 No.185 和風
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-19 06:35:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 210 ms / 1,000 ms
コード長 546 bytes
コンパイル時間 3,214 ms
コンパイル使用メモリ 78,804 KB
実行使用メモリ 43,616 KB
最終ジャッジ日時 2024-04-19 08:29:13
合計ジャッジ時間 5,113 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
42,140 KB
testcase_01 AC 176 ms
43,416 KB
testcase_02 AC 194 ms
43,616 KB
testcase_03 AC 199 ms
43,192 KB
testcase_04 AC 210 ms
43,612 KB
testcase_05 AC 148 ms
41,492 KB
testcase_06 AC 182 ms
43,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise96{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int[][] x = new int[n][2];
    for(int i = 0; i < n; i++){
      x[i][0] = sc.nextInt();
      x[i][1] = sc.nextInt();
    }

    int a = x[0][1] - x[0][0];
    if(a < 1){
      System.out.println(-1);
      return;
    }

    for(int i = 1; i < n; i++){
      if(x[i][1] - x[i][0] != a){
        System.out.println(-1);
        return;
      }
    }
    System.out.println(a);
  }
}
0