結果

問題 No.185 和風
ユーザー yun_appyun_app
提出日時 2016-05-12 12:48:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 82 ms / 1,000 ms
コード長 940 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 38,368 KB
最終ジャッジ日時 2024-04-15 15:17:38
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
37,164 KB
testcase_01 AC 76 ms
38,316 KB
testcase_02 AC 51 ms
36,644 KB
testcase_03 AC 52 ms
37,284 KB
testcase_04 AC 81 ms
37,928 KB
testcase_05 AC 54 ms
37,248 KB
testcase_06 AC 82 ms
38,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        if(n==1){
            System.out.println(-1);
            return;
        }
        String[] lines = br.readLine().split(" ");
        int ans = Integer.parseInt(lines[1]) - Integer.parseInt(lines[0]);
        for(int i=1;i<n;i++){
            lines = br.readLine().split(" ");
            if(Integer.parseInt(lines[1]) - Integer.parseInt(lines[0]) != ans){
                System.out.println(-1);
                return;
            }
        }
        System.out.println(ans>0?ans:-1);
    }
}
0