結果

問題 No.185 和風
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-09 18:13:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 73,916 KB
実行使用メモリ 43,552 KB
最終ジャッジ日時 2024-04-16 19:08:19
合計ジャッジ時間 3,961 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 179 ms
41,964 KB
testcase_01 AC 198 ms
43,456 KB
testcase_02 AC 197 ms
43,548 KB
testcase_03 AC 199 ms
43,392 KB
testcase_04 AC 193 ms
43,212 KB
testcase_05 WA -
testcase_06 AC 196 ms
43,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			ar[i] = b - a;
		}
		
		boolean exist = true;
		for (int i=0; i<n-1; i++) {
			if (ar[i]!=ar[i+1]) {exist = false;}
		}
		
		if (exist==false) {
			System.out.println(-1);
		}
		else {
			if (ar[0]<0) {System.out.println(-1);}
			else {System.out.println(ar[0]);}
		}
	}
}
0