結果

問題 No.185 和風
ユーザー mits58mits58
提出日時 2016-07-02 21:53:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 188 ms / 1,000 ms
コード長 416 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 78,384 KB
実行使用メモリ 43,696 KB
最終ジャッジ日時 2024-04-20 06:11:14
合計ジャッジ時間 4,065 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
41,992 KB
testcase_01 AC 188 ms
43,292 KB
testcase_02 AC 186 ms
43,376 KB
testcase_03 AC 180 ms
43,168 KB
testcase_04 AC 178 ms
42,916 KB
testcase_05 AC 135 ms
41,616 KB
testcase_06 AC 184 ms
43,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int ans=sc.nextInt()-sc.nextInt(); ans=-ans;
			for(int i=1;i<n;i++){
				int x=sc.nextInt();
				int y=sc.nextInt();
				int temp=y-x;
				if(ans==-1) continue;
				if(ans!=temp) ans=-1;
			}
			System.out.println(ans<=0 ? -1 : ans);
		}
	}
}
0