結果

問題 No.185 和風
ユーザー misk703misk703
提出日時 2018-05-14 12:42:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 209 ms / 1,000 ms
コード長 583 bytes
コンパイル時間 3,624 ms
コンパイル使用メモリ 72,752 KB
実行使用メモリ 58,412 KB
最終ジャッジ日時 2023-09-10 19:45:58
合計ジャッジ時間 5,769 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 196 ms
55,852 KB
testcase_01 AC 209 ms
57,916 KB
testcase_02 AC 203 ms
55,812 KB
testcase_03 AC 202 ms
58,208 KB
testcase_04 AC 205 ms
58,412 KB
testcase_05 AC 151 ms
55,588 KB
testcase_06 AC 205 ms
57,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class Wahu {

    public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = Integer.parseInt(s.nextLine());
	ArrayList<Integer> list = new ArrayList<>();
	for(int i=0;i<N;i++){
	    int a = s.nextInt();
	    int b = s.nextInt();
	    list.add(b-a);
	}
	int buff = list.get(0);
	if(buff <= 0){
	    System.out.println(-1);
	    return;
	}
	for(int i=1;i<list.size();i++){
	    if(buff != list.get(i)){
		System.out.println(-1);
		return;
	    }
	}
	System.out.println(buff);
	return;
    }

}
0