結果

問題 No.185 和風
ユーザー tenten
提出日時 2020-11-10 17:25:36
言語 Java
(openjdk 23)
結果
AC  
実行時間 174 ms / 1,000 ms
コード長 524 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 73,864 KB
実行使用メモリ 43,512 KB
最終ジャッジ日時 2024-07-22 17:36:30
合計ジャッジ時間 3,437 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

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