結果

問題 No.185 和風
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-15 17:27:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 1,000 ms
コード長 569 bytes
コンパイル時間 2,546 ms
コンパイル使用メモリ 72,176 KB
実行使用メモリ 56,604 KB
最終ジャッジ日時 2023-08-11 04:40:03
合計ジャッジ時間 3,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
56,604 KB
testcase_01 AC 189 ms
41,940 KB
testcase_02 AC 192 ms
41,076 KB
testcase_03 AC 187 ms
41,088 KB
testcase_04 AC 187 ms
41,856 KB
testcase_05 AC 136 ms
39,584 KB
testcase_06 AC 196 ms
41,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0 ; i < n ; i++) {
			x[i] =sc.nextInt();
			y[i] = sc.nextInt();
		}
		long[] a = new long[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = y[i] - x[i];
		}
		for(int i = 0 ; i < n ; i++) {
			for(int j = i + 1 ; j < n ; j++) {
				if(a[i] != a[j] || a[i] <= 0) {
					System.out.println(-1);
					return;
				}
			}
		}
		System.out.println(a[0]);
 	}
}
0