結果

問題 No.185 和風
ユーザー marumaru
提出日時 2016-03-22 21:51:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 208 ms / 1,000 ms
コード長 561 bytes
コンパイル時間 3,438 ms
コンパイル使用メモリ 74,452 KB
実行使用メモリ 60,360 KB
最終ジャッジ日時 2024-04-08 22:16:00
合計ジャッジ時間 5,471 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 192 ms
58,356 KB
testcase_01 AC 201 ms
60,360 KB
testcase_02 AC 202 ms
60,284 KB
testcase_03 AC 208 ms
60,332 KB
testcase_04 AC 206 ms
60,348 KB
testcase_05 AC 155 ms
58,100 KB
testcase_06 AC 208 ms
60,296 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