結果

問題 No.185 和風
ユーザー TatsuDXTatsuDX
提出日時 2016-09-09 00:19:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 184 ms / 1,000 ms
コード長 423 bytes
コンパイル時間 3,670 ms
コンパイル使用メモリ 74,168 KB
実行使用メモリ 56,620 KB
最終ジャッジ日時 2024-04-27 18:19:12
合計ジャッジ時間 4,401 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
54,316 KB
testcase_01 AC 169 ms
56,620 KB
testcase_02 AC 109 ms
53,652 KB
testcase_03 AC 111 ms
53,728 KB
testcase_04 AC 112 ms
53,800 KB
testcase_05 AC 113 ms
54,268 KB
testcase_06 AC 184 ms
56,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), d = b - a;
		if(d <= 0){
			System.out.println(-1);
			return;
		}
		for(int i = 1; i < n; i++){
			a = sc.nextInt();
			b = sc.nextInt();
			if(d != b-a){
				System.out.println(-1);
				return;
			}
		}
		System.out.println(d);
	}
}
0