結果

問題 No.185 和風
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-26 00:09:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 74,272 KB
実行使用メモリ 59,988 KB
最終ジャッジ日時 2023-10-23 20:08:18
合計ジャッジ時間 4,714 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 198 ms
59,884 KB
testcase_02 AC 200 ms
59,888 KB
testcase_03 AC 195 ms
59,812 KB
testcase_04 AC 199 ms
59,812 KB
testcase_05 AC 146 ms
57,552 KB
testcase_06 WA -
権限があれば一括ダウンロードができます

ソースコード

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) {
            ans = -1;
        }

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

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