結果

問題 No.185 和風
ユーザー k_kadorak_kadora
提出日時 2015-06-10 00:06:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 192 ms / 1,000 ms
コード長 485 bytes
コンパイル時間 3,986 ms
コンパイル使用メモリ 72,012 KB
実行使用メモリ 58,292 KB
最終ジャッジ日時 2023-09-20 20:26:59
合計ジャッジ時間 5,223 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
56,852 KB
testcase_01 AC 192 ms
58,112 KB
testcase_02 AC 191 ms
58,292 KB
testcase_03 AC 192 ms
58,064 KB
testcase_04 AC 189 ms
57,848 KB
testcase_05 AC 137 ms
55,828 KB
testcase_06 AC 191 ms
58,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Wafu {
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int n,temp=0,res=0;
		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();
		}
		for(int i = 0;i<n;i++){
			if(i ==0){
				temp = y[i] - x[i];
				res = temp;
			}
			if(y[i] - x[i]<= 0 || y[i] - x[i] != temp) {
				res = -1;
				break;
			}
		}
		System.out.println(res);
	}
}
0