結果

問題 No.185 和風
ユーザー spacenautspacenaut
提出日時 2016-05-18 00:14:38
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 690 bytes
コンパイル時間 2,389 ms
コンパイル使用メモリ 74,900 KB
実行使用メモリ 43,872 KB
最終ジャッジ日時 2024-04-15 22:51:19
合計ジャッジ時間 4,585 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 205 ms
43,456 KB
testcase_03 RE -
testcase_04 AC 212 ms
43,148 KB
testcase_05 RE -
testcase_06 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class No0185{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n  = sc.nextInt();
		int result = 0;
		ArrayList<Integer> x = new ArrayList<Integer>();
		ArrayList<Integer> y = new ArrayList<Integer>();
		ArrayList<Integer> z = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			x.add(sc.nextInt());
			x.set(i, (sc.nextInt() - x.get(i)));
		}
		for(int i = 0; i < n; i++){
			if(x.get(i) < 0 || x.get(i - 1) < 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