結果

問題 No.185 和風
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-26 00:09:42
言語 Java19
(openjdk 21)
結果
AC  
実行時間 204 ms / 1,000 ms
コード長 635 bytes
コンパイル時間 2,493 ms
コンパイル使用メモリ 74,352 KB
実行使用メモリ 59,888 KB
最終ジャッジ日時 2023-10-23 20:08:35
合計ジャッジ時間 4,701 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
57,608 KB
testcase_01 AC 204 ms
59,852 KB
testcase_02 AC 195 ms
59,844 KB
testcase_03 AC 193 ms
59,712 KB
testcase_04 AC 194 ms
59,876 KB
testcase_05 AC 155 ms
57,540 KB
testcase_06 AC 198 ms
59,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i=0; i<n; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
        }

        int answer = y[0] - x[0];
        int ans = 0;

        if(answer <= 0) {
            answer = -1;
        }

        for(int i=1; i<n; i++) {
            if(y[i] - x[i] != answer) {
                answer = -1;
            }
        }

        System.out.println(answer);
    }
}
0