結果

問題 No.185 和風
コンテスト
ユーザー spacia
提出日時 2015-12-16 01:33:25
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 41 ms / 1,000 ms
コード長 648 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,286 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 39,248 KB
最終ジャッジ日時 2026-04-05 10:44:42
合計ジャッジ時間 2,382 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.*;
import java.util.*;
import java.math.*;

class Main185 {
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		int ans = -1;
		boolean flg = false;
		for (int i = 0; i < n; i++) {
			if (flg) continue;
			String[] str = br.readLine().split(" ");
			int sub = Integer.parseInt(str[1]) - Integer.parseInt(str[0]);
			if (sub < 1) {
				flg = true;
				continue;
			}
			if (i == 0) {
				ans = sub;
			} else if (ans != sub) {
				flg = true;
			}
		}
		System.out.println(flg ? -1 : ans);
	}
}
0