結果

問題 No.185 和風
ユーザー ffmm00ffmm00
提出日時 2015-06-03 19:13:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 208 ms / 1,000 ms
コード長 542 bytes
コンパイル時間 3,381 ms
コンパイル使用メモリ 72,400 KB
実行使用メモリ 58,460 KB
最終ジャッジ日時 2023-09-20 19:01:08
合計ジャッジ時間 5,336 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
55,896 KB
testcase_01 AC 208 ms
58,460 KB
testcase_02 AC 129 ms
55,440 KB
testcase_03 AC 127 ms
55,280 KB
testcase_04 AC 127 ms
55,332 KB
testcase_05 AC 127 ms
55,304 KB
testcase_06 AC 200 ms
58,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class N185 {

	public static void main(String[] args) {

		Scanner sca = new Scanner(System.in);
		int N = sca.nextInt();
		int[] A = new int[N];

		for (int i = 0; i < N; i++) {
			int X = sca.nextInt();
			int Y = sca.nextInt();
			A[i] = Y - X;
			if (A[i] <= 0) {
				System.out.println(-1);
				return;
			}
		}

		Arrays.sort(A);

		for (int i = 0; i < N - 1; i++) {
			if (A[i] != A[i + 1]) {
				System.out.println(-1);
				return;
			}
		}

		System.out.println(A[0]);
	}

}
0