結果

問題 No.185 和風
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2015-06-24 17:59:03
言語 Java19
(openjdk 21)
結果
AC  
実行時間 200 ms / 1,000 ms
コード長 619 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 72,420 KB
実行使用メモリ 58,480 KB
最終ジャッジ日時 2023-09-22 00:33:40
合計ジャッジ時間 4,083 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 187 ms
56,020 KB
testcase_01 AC 200 ms
58,480 KB
testcase_02 AC 198 ms
58,036 KB
testcase_03 AC 199 ms
58,360 KB
testcase_04 AC 196 ms
58,184 KB
testcase_05 AC 149 ms
56,144 KB
testcase_06 AC 199 ms
58,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	static int N;
	static int[] X,Y;
	
	public static int solve(){
		int answer = Y[0] - X[0];
		
		if (answer <= 0) return -1;
		
		for (int i = 1; i < N; i++) {
			if (Y[i] - X[i] != answer) return -1;
		}
		
		return answer;
	}
	
	public static void main(String[] args){
		Scanner S = new Scanner(System.in);
		
		N = S.nextInt();
		
		X = new int[N];
		Y = new int[N];

		for (int i = 0; i < N; i++) {
			X[i] = S.nextInt();
			Y[i] = S.nextInt();
		}
		
		System.out.println(solve());
	}
}
0