結果

問題 No.185 和風
ユーザー YamaKasaYamaKasa
提出日時 2018-04-27 02:11:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 1,000 ms
コード長 558 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 71,172 KB
実行使用メモリ 58,584 KB
最終ジャッジ日時 2023-09-10 06:00:38
合計ジャッジ時間 4,061 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
55,764 KB
testcase_01 AC 196 ms
58,584 KB
testcase_02 AC 193 ms
58,252 KB
testcase_03 AC 192 ms
58,284 KB
testcase_04 AC 195 ms
57,816 KB
testcase_05 AC 141 ms
55,372 KB
testcase_06 AC 194 ms
58,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []X = new int[N];
		int []Y = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = scan.nextInt();
			Y[i] = scan.nextInt();
		}
		scan.close();
		int z = Y[0] - X[0];
		if(z <= 0) {
			System.out.println(-1);
			System.exit(0);
		}
		for(int i = 1; i < N; i++) {
			int temp = Y[i] - X[i];
			if(z != temp) {
				System.out.println(-1);
				System.exit(0);
			}
		}
		System.out.println(z);
	}
}
0