結果

問題 No.185 和風
ユーザー kenkooookenkoooo
提出日時 2015-04-19 23:29:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 203 ms / 1,000 ms
コード長 457 bytes
コンパイル時間 3,549 ms
コンパイル使用メモリ 71,748 KB
実行使用メモリ 58,728 KB
最終ジャッジ日時 2023-09-18 01:21:54
合計ジャッジ時間 5,290 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
56,128 KB
testcase_01 AC 203 ms
58,728 KB
testcase_02 AC 129 ms
55,684 KB
testcase_03 AC 128 ms
55,720 KB
testcase_04 AC 127 ms
55,644 KB
testcase_05 AC 125 ms
55,748 KB
testcase_06 AC 199 ms
58,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int candidate = 0;
		for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if (i == 0) {
				candidate = y - x;
			}
			if (candidate <= 0 || candidate != y - x) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(candidate);

	}

}
0