結果

問題 No.185 和風
ユーザー spaciaspacia
提出日時 2015-12-16 01:33:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 73 ms / 1,000 ms
コード長 648 bytes
コンパイル時間 4,076 ms
コンパイル使用メモリ 71,604 KB
実行使用メモリ 50,636 KB
最終ジャッジ日時 2023-10-14 10:32:49
合計ジャッジ時間 3,052 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
49,524 KB
testcase_01 AC 63 ms
50,532 KB
testcase_02 AC 40 ms
49,220 KB
testcase_03 AC 41 ms
49,412 KB
testcase_04 AC 41 ms
49,252 KB
testcase_05 AC 40 ms
47,256 KB
testcase_06 AC 73 ms
50,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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