結果

問題 No.185 和風
ユーザー 37zigen37zigen
提出日時 2016-03-31 13:22:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 202 ms / 1,000 ms
コード長 470 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 74,484 KB
実行使用メモリ 56,844 KB
最終ジャッジ日時 2024-04-10 06:44:23
合計ジャッジ時間 3,837 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
54,152 KB
testcase_01 AC 202 ms
56,408 KB
testcase_02 AC 132 ms
54,000 KB
testcase_03 AC 132 ms
53,764 KB
testcase_04 AC 131 ms
54,092 KB
testcase_05 AC 131 ms
54,184 KB
testcase_06 AC 199 ms
56,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder185;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int res=-1;
		for(int i=0;i<n;i++){
			int x=sc.nextInt();
			int y=sc.nextInt();
			if(i==0){
				if(y-x>0){
					res=y-x;
				}else{
					System.out.println(-1);
					return;
				}
			}else{
				if(y-x!=res){
					System.out.println(-1);
					return;
				}
			}
		}
		System.out.println(res);
	}
}
0