結果

問題 No.185 和風
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-13 05:55:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 694 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 71,576 KB
実行使用メモリ 59,096 KB
最終ジャッジ日時 2023-08-17 04:08:04
合計ジャッジ時間 3,774 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
56,320 KB
testcase_01 AC 198 ms
58,312 KB
testcase_02 AC 121 ms
55,796 KB
testcase_03 AC 121 ms
55,688 KB
testcase_04 AC 122 ms
55,496 KB
testcase_05 AC 122 ms
55,876 KB
testcase_06 AC 198 ms
59,096 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 [] X = new int [N];
        int [] Y = new int [N];
        X[0] = sc.nextInt();
        Y[0] = sc.nextInt();
        int d = Y[0] - X[0];
        int r = d;
        if(d>=1){
            for(int i=1; i<N; i++){
                X[i] = sc.nextInt();
                Y[i] = sc.nextInt();
                int temp = Y[i] - X[i];
                if(d!=temp){
                    r=-1;
                    break;
                }
            }
        }else{
            r=-1;
        }
        System.out.println(r);
    }
}
0