結果

問題 No.185 和風
コンテスト
ユーザー _k_a_n_i_
提出日時 2015-04-23 18:03:57
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 858 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,688 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 46,388 KB
最終ジャッジ日時 2026-03-26 07:01:53
合計ジャッジ時間 2,864 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Scanner;

public class Main
{
    private final static Main main = new Main();

    public static void main(String[] args)
    {
        long l = System.currentTimeMillis();
        main.solve();
        //System.out.println("処理時間:" + (System.currentTimeMillis() - l));
    }

    private void solve()
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = (sc.nextInt()-sc.nextInt())*-1;
        boolean flag = false;
        for(int i=1; i<n; ++i)
        {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(ans + x == y)
            {
                flag = true;
            }
            else
            {
                flag = false;
                break;
            }
        }
        System.out.println(flag && ans > 0 ? ans : -1);
    }
}
0