結果

問題 No.185 和風
ユーザー rf141rf141
提出日時 2015-12-20 17:43:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 211 ms / 1,000 ms
コード長 531 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 74,256 KB
実行使用メモリ 60,040 KB
最終ジャッジ日時 2023-10-17 14:31:52
合計ジャッジ時間 4,479 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 192 ms
57,688 KB
testcase_01 AC 196 ms
59,628 KB
testcase_02 AC 209 ms
59,676 KB
testcase_03 AC 207 ms
59,844 KB
testcase_04 AC 211 ms
60,040 KB
testcase_05 AC 155 ms
57,668 KB
testcase_06 AC 210 ms
59,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
public class Main{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		System.out.println(Calc(n,scan));
	}

	public static int Calc(int n,Scanner scan){
		int result = -1;
		for(int i = 0; i < n; i++){
			int x = scan.nextInt();
			int y = scan.nextInt();

			int fx = y-x;

			if(i == 0 && 0 < fx){
				result = fx;
			}else if(result != fx){
				result = -1;
			}else if(fx <= 0){
				result = -1;
			}
		}

		return result;
	}
}
0