結果

問題 No.185 和風
ユーザー nCk_cvnCk_cv
提出日時 2015-04-20 12:13:05
言語 Java19
(openjdk 21)
結果
AC  
実行時間 200 ms / 1,000 ms
コード長 426 bytes
コンパイル時間 1,991 ms
コンパイル使用メモリ 70,868 KB
実行使用メモリ 58,796 KB
最終ジャッジ日時 2023-09-18 00:39:00
合計ジャッジ時間 4,598 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 181 ms
56,116 KB
testcase_01 AC 194 ms
57,960 KB
testcase_02 AC 198 ms
58,796 KB
testcase_03 AC 200 ms
58,008 KB
testcase_04 AC 197 ms
58,028 KB
testcase_05 AC 144 ms
56,188 KB
testcase_06 AC 193 ms
57,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = -1;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			int c = b - a;
			
			if(i == 0 && c > 0) {
				ans = c;
			}
			else if(ans != c) {
				ans = -1;
			}
			else if(c <= 0) {
				ans = -1;
			}
		}
		System.out.println(ans);
	}
}	
			
0