結果

問題 No.185 和風
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-15 17:23:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 79,484 KB
実行使用メモリ 58,520 KB
最終ジャッジ日時 2024-04-28 21:35:11
合計ジャッジ時間 4,213 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
42,264 KB
testcase_01 WA -
testcase_02 AC 209 ms
42,896 KB
testcase_03 AC 194 ms
43,460 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 203 ms
43,280 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