結果

問題 No.185 和風
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-27 09:02:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 1,000 ms
コード長 552 bytes
コンパイル時間 3,792 ms
コンパイル使用メモリ 72,388 KB
実行使用メモリ 58,624 KB
最終ジャッジ日時 2023-08-09 20:11:52
合計ジャッジ時間 5,841 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
56,240 KB
testcase_01 AC 191 ms
58,140 KB
testcase_02 AC 192 ms
58,008 KB
testcase_03 AC 193 ms
58,144 KB
testcase_04 AC 195 ms
58,624 KB
testcase_05 AC 140 ms
55,820 KB
testcase_06 AC 193 ms
58,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No185 {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N*2];
		for (int i=0; i< N * 2; i++)
			input[i] = sc.nextInt();
		int dif = input[1] - input[0];
		int count = 0;
		
		if(dif <= 0)
			System.out.println("-1");
		else{
			for(int i=0; i < N * 2; i = i + 2){
			if(input[i] + dif == input[i+1])
				count++;
			}
		if(count ==N )
			System.out.println(dif);
		else
			System.out.println("-1");
	    
		sc.close();
		}
	}
}
0