結果

問題 No.185 和風
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-30 11:00:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 71 ms / 1,000 ms
コード長 1,014 bytes
コンパイル時間 2,648 ms
コンパイル使用メモリ 72,344 KB
実行使用メモリ 51,948 KB
最終ジャッジ日時 2023-10-11 23:32:38
合計ジャッジ時間 3,186 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
49,412 KB
testcase_01 AC 71 ms
51,948 KB
testcase_02 AC 42 ms
49,408 KB
testcase_03 AC 43 ms
49,716 KB
testcase_04 AC 43 ms
49,108 KB
testcase_05 AC 43 ms
49,384 KB
testcase_06 AC 65 ms
50,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        String[] inputs;
        long answer = -1;
        for (int i = 0; i < N; i++) {
            inputs = reader.readLine().split(" ");
            long x = Long.parseLong(inputs[0]);
            long y = Long.parseLong(inputs[1]);
            if (y - x > 0) {
                if (answer != -1 && answer != y - x) {
                    answer = -1;
                    break;
                } else {
                    answer = y-x;
                }
            } else {
                answer=-1;
                break;
            }
        }
        System.out.println(answer);
    }
}
0