結果

問題 No.185 和風
ユーザー r.suzukir.suzuki
提出日時 2015-12-28 21:32:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 211 ms / 1,000 ms
コード長 456 bytes
コンパイル時間 4,085 ms
コンパイル使用メモリ 75,344 KB
実行使用メモリ 43,676 KB
最終ジャッジ日時 2023-10-19 11:52:54
合計ジャッジ時間 5,212 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 187 ms
41,988 KB
testcase_01 AC 209 ms
43,368 KB
testcase_02 AC 136 ms
41,188 KB
testcase_03 AC 137 ms
41,124 KB
testcase_04 AC 211 ms
43,676 KB
testcase_05 AC 155 ms
41,880 KB
testcase_06 AC 204 ms
43,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

public class No_185 {

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = y - x;

		for (int i = 1; i < n; i++) {
			x = sc.nextInt();
			y = sc.nextInt();
			if (ans != y - x) {
				ans = -1;
				break;
			}
		}

		if (ans > 0) {
			System.out.println(ans);
		} else {
			System.out.println(-1);
		}
		sc.close();

	}

}
0