結果

問題 No.185 和風
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-19 23:27:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 815 bytes
コンパイル時間 3,074 ms
コンパイル使用メモリ 71,716 KB
実行使用メモリ 58,520 KB
最終ジャッジ日時 2023-09-18 01:20:28
合計ジャッジ時間 5,199 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
56,956 KB
testcase_01 AC 199 ms
58,520 KB
testcase_02 AC 196 ms
58,080 KB
testcase_03 AC 199 ms
57,748 KB
testcase_04 AC 199 ms
57,872 KB
testcase_05 WA -
testcase_06 AC 198 ms
58,088 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