結果

問題 No.185 和風
ユーザー tentententen
提出日時 2020-11-10 17:25:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 524 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 71,576 KB
実行使用メモリ 58,828 KB
最終ジャッジ日時 2023-09-29 23:41:06
合計ジャッジ時間 3,827 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 186 ms
56,300 KB
testcase_01 AC 197 ms
58,216 KB
testcase_02 AC 124 ms
55,960 KB
testcase_03 AC 126 ms
55,684 KB
testcase_04 AC 124 ms
55,684 KB
testcase_05 AC 124 ms
56,356 KB
testcase_06 AC 198 ms
58,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = -(sc.nextInt() - sc.nextInt());
        if (ans <= 0) {
            System.out.println(-1);
            return;
        }
        for (int i = 1; i < n; i++) {
            if (ans != -(sc.nextInt() - sc.nextInt())) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(ans);
    }
}
0