結果

問題 No.185 和風
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-27 09:02:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 183 ms / 1,000 ms
コード長 552 bytes
コンパイル時間 2,884 ms
コンパイル使用メモリ 75,700 KB
実行使用メモリ 56,584 KB
最終ジャッジ日時 2024-04-27 14:43:14
合計ジャッジ時間 4,598 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
54,228 KB
testcase_01 AC 171 ms
56,584 KB
testcase_02 AC 175 ms
56,352 KB
testcase_03 AC 183 ms
56,252 KB
testcase_04 AC 174 ms
56,380 KB
testcase_05 AC 124 ms
53,540 KB
testcase_06 AC 176 ms
56,568 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