結果

問題 No.185 和風
ユーザー kou6839kou6839
提出日時 2015-04-22 12:02:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 71,540 KB
実行使用メモリ 58,180 KB
最終ジャッジ日時 2023-09-18 08:09:17
合計ジャッジ時間 3,923 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 181 ms
56,020 KB
testcase_01 AC 195 ms
57,928 KB
testcase_02 AC 123 ms
55,888 KB
testcase_03 AC 123 ms
55,676 KB
testcase_04 AC 121 ms
56,248 KB
testcase_05 AC 123 ms
55,972 KB
testcase_06 AC 195 ms
58,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main {
	static int[] tatesum,yokosum;
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans=0;
		for(int i=0;i<n;i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(y-x>0){
				if(ans==0){
					ans=y-x;
				}else{
					if(ans==y-x){
						
					}else{
						System.out.println(-1);
						return;
					}
				}
			}else{
				System.out.println(-1);
				return;
			}
		}
		System.out.println(ans);
	}
}
0