結果

問題 No.185 和風
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-19 23:31:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 203 ms / 1,000 ms
コード長 816 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 71,604 KB
実行使用メモリ 58,596 KB
最終ジャッジ日時 2023-09-18 01:23:44
合計ジャッジ時間 4,098 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
56,052 KB
testcase_01 AC 199 ms
58,560 KB
testcase_02 AC 203 ms
58,568 KB
testcase_03 AC 202 ms
57,988 KB
testcase_04 AC 197 ms
58,596 KB
testcase_05 AC 149 ms
55,732 KB
testcase_06 AC 200 ms
58,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int n = koko.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i=0; i<n; i++){
            x[i]=koko.nextInt();
            y[i]=koko.nextInt();
        }
        int ans = y[0]-x[0];
        if(ans<=0){
            System.out.println(-1);
        }else{
            boolean wflag = false;
            for(int i=1; i<n; i++){
                int b = y[i]-x[i];
                if(b!=ans){
                    System.out.println(-1);
                    wflag=true;
                    break;
                }
            }
            if(!wflag){
                System.out.println(ans);
            }
        }
    }
}
0