結果

問題 No.185 和風
ユーザー marumaru
提出日時 2016-03-22 21:51:50
言語 Java19
(openjdk 21)
結果
AC  
実行時間 189 ms / 1,000 ms
コード長 561 bytes
コンパイル時間 4,161 ms
コンパイル使用メモリ 72,608 KB
実行使用メモリ 58,584 KB
最終ジャッジ日時 2023-07-24 17:58:16
合計ジャッジ時間 5,867 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
54,332 KB
testcase_01 AC 189 ms
58,216 KB
testcase_02 AC 187 ms
58,364 KB
testcase_03 AC 189 ms
58,452 KB
testcase_04 AC 188 ms
58,584 KB
testcase_05 AC 141 ms
55,792 KB
testcase_06 AC 182 ms
58,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class yukicoder_185 {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		int[] y = new int[n];
			
		for (int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			y[i] = stdIn.nextInt();
		}
		
		int answer = -1;
		int diff = y[0] - x[0];
		
		if (diff >= 1) {
			for (int i = 1; i < n; i++) {
				if (x[i] + diff == y[i]) {
					answer = diff;
				} else {
					answer = -1;
					break;
				}
			}
		}
		System.out.println(answer);
	}
}
0