結果

問題 No.185 和風
ユーザー r.suzuki
提出日時 2015-12-28 21:32:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 179 ms / 1,000 ms
コード長 456 bytes
コンパイル時間 3,363 ms
コンパイル使用メモリ 74,736 KB
実行使用メモリ 43,468 KB
最終ジャッジ日時 2024-09-19 07:59:06
合計ジャッジ時間 4,530 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

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