結果

問題 No.185 和風
ユーザー shinwisteriashinwisteria
提出日時 2018-02-21 22:38:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 204 ms / 1,000 ms
コード長 520 bytes
コンパイル時間 3,491 ms
コンパイル使用メモリ 74,708 KB
実行使用メモリ 59,892 KB
最終ジャッジ日時 2023-10-20 00:08:42
合計ジャッジ時間 5,497 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 199 ms
57,816 KB
testcase_01 AC 198 ms
59,728 KB
testcase_02 AC 203 ms
59,892 KB
testcase_03 AC 200 ms
59,660 KB
testcase_04 AC 204 ms
59,676 KB
testcase_05 AC 149 ms
57,620 KB
testcase_06 AC 202 ms
59,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package m.shin;
import java.util.Scanner;
public class Con185 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt() , d = 0;
		int[] X = new int[N];
		int[] Y = new int[N];
		for(int i = 0;i < N;i++){
			X[i] = s.nextInt();
			Y[i] = s.nextInt();
			if(i >= 1){
				if(d != Y[i] - X[i] || Y[i] - X[i] <= 0){
					d = -1;
				}
			}else{
				if(Y[i] - X[i] <= 0){
					d = -1;
				}else{
					d = Y[i] - X[i];
				}
			}
		}
		s.close();

		System.out.println(d);
	}

}
0