結果

問題 No.185 和風
ユーザー spacenautspacenaut
提出日時 2016-05-22 18:46:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 75,540 KB
実行使用メモリ 56,552 KB
最終ジャッジ日時 2024-04-16 06:49:20
合計ジャッジ時間 4,335 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 192 ms
42,112 KB
testcase_01 AC 211 ms
43,580 KB
testcase_02 AC 210 ms
43,780 KB
testcase_03 AC 213 ms
43,928 KB
testcase_04 AC 212 ms
43,392 KB
testcase_05 WA -
testcase_06 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class No0185{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n  = sc.nextLong();
		long result = 0;
		ArrayList<Long> x = new ArrayList<Long>();

		for(int i = 0; i < n; i++){
			x.add(sc.nextLong());
			x.set(i, (sc.nextLong() - x.get(i)));
		}

		for(int i = 0; i < n; i++){
			if(x.get(i) < 0){
				result = -1;
				break;
			}
			if(x.get(i) != x.get(i + 1)){
				result = -1;
				break;
			}
			if(i == n - 2){
				break;
			}
		}
		
		if(result != -1) result = x.get(0);
		System.out.println(result);
	}
}
0