結果

問題 No.185 和風
ユーザー jimano
提出日時 2018-01-13 19:30:54
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 3,384 ms
コンパイル使用メモリ 78,120 KB
実行使用メモリ 54,028 KB
最終ジャッジ日時 2024-12-24 00:57:27
合計ジャッジ時間 5,316 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;
import java.util.Scanner;

public class No0185 {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int ans = y - x;

			if (ans < 0) {
				System.out.println("-1");
			} else {
				for (int i = 0; i < N - 1; i++) {
					x = sc.nextInt();
					y = sc.nextInt();

					if (ans != y - x) {
						ans = -1;
						break;
					}
				}
				System.out.println(ans);
			}
		}
	}
}
0