結果

問題 No.185 和風
ユーザー jimanojimano
提出日時 2018-01-13 19:30:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 3,487 ms
コンパイル使用メモリ 72,628 KB
実行使用メモリ 58,764 KB
最終ジャッジ日時 2023-08-25 16:00:08
合計ジャッジ時間 4,312 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
55,776 KB
testcase_01 AC 163 ms
58,764 KB
testcase_02 AC 100 ms
55,984 KB
testcase_03 AC 99 ms
56,124 KB
testcase_04 AC 97 ms
55,848 KB
testcase_05 WA -
testcase_06 AC 160 ms
58,696 KB
権限があれば一括ダウンロードができます

ソースコード

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