結果

問題 No.185 和風
ユーザー YatsukuYatsuku
提出日時 2015-12-16 17:25:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 1,000 ms
コード長 569 bytes
コンパイル時間 2,159 ms
コンパイル使用メモリ 71,848 KB
実行使用メモリ 59,088 KB
最終ジャッジ日時 2023-10-14 10:50:18
合計ジャッジ時間 4,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 179 ms
56,068 KB
testcase_01 AC 195 ms
58,208 KB
testcase_02 AC 124 ms
55,656 KB
testcase_03 AC 126 ms
55,216 KB
testcase_04 AC 122 ms
55,792 KB
testcase_05 AC 120 ms
55,512 KB
testcase_06 AC 190 ms
59,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class No_185 {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);		
		int num = stdIn.nextInt();
		int [] unknown = new int [num];

		for (int i = 0; i < num; i++) {
			int x1 = stdIn.nextInt();
			int x2 = stdIn.nextInt();
			if ( x1 < x2 ) {
				unknown[i] = x2 - x1;
			} else {
				System.out.println(-1);
				System.exit(0);
			}
		}

		for (int i = 0; i < num-1; i++) {
			if (unknown[i] != unknown[i+1]) {
				System.out.println(-1);
				System.exit(0);
			}
		}
		System.out.println(unknown[0]);
	}
}
0