結果

問題 No.185 和風
ユーザー samplelpmassamplelpmas
提出日時 2016-11-17 04:18:29
言語 Java19
(openjdk 21)
結果
AC  
実行時間 195 ms / 1,000 ms
コード長 658 bytes
コンパイル時間 3,461 ms
コンパイル使用メモリ 70,852 KB
実行使用メモリ 58,584 KB
最終ジャッジ日時 2023-08-17 07:50:02
合計ジャッジ時間 5,100 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 185 ms
55,984 KB
testcase_01 AC 195 ms
58,584 KB
testcase_02 AC 122 ms
55,564 KB
testcase_03 AC 123 ms
55,584 KB
testcase_04 AC 124 ms
56,272 KB
testcase_05 AC 124 ms
55,896 KB
testcase_06 AC 191 ms
57,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int xFirst = sc.nextInt();
        int yFirst = sc.nextInt();

        int answer = yFirst - xFirst;

        if (answer <= 0) {
            System.out.println(-1);
            return;
        }

        for (int i = 0; i < n - 1; i++) {

            int x = sc.nextInt();
            int y = sc.nextInt();

            if (answer != y - x) {
                System.out.println(-1);
                return;
            }

        }

        System.out.println(answer);

    }

}
0