結果

問題 No.185 和風
ユーザー kohaku_kohaku
提出日時 2016-11-13 05:55:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 193 ms / 1,000 ms
コード長 694 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 73,924 KB
実行使用メモリ 48,684 KB
最終ジャッジ日時 2024-11-25 21:46:00
合計ジャッジ時間 3,593 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

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