結果

問題 No.185 和風
ユーザー h_tyokinuhatah_tyokinuhata
提出日時 2016-01-24 19:49:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 74,616 KB
実行使用メモリ 60,420 KB
最終ジャッジ日時 2023-10-21 14:55:58
合計ジャッジ時間 3,370 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 164 ms
59,856 KB
testcase_02 AC 165 ms
59,732 KB
testcase_03 AC 173 ms
58,240 KB
testcase_04 AC 171 ms
59,552 KB
testcase_05 WA -
testcase_06 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		
		int[] X = new int[N], Y = new int[N];
		
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		
		int[] Z = new int[N];
		
		for(int i = 0; i < N; i++) {
			Z[i] = Y[i] - X[i];
		}
		
		int cnt = 0;
		
		for(int i = 0; i < N; i++) {
			if(Z[0] == Z[i] && Z[i] >= 0) {
				cnt++;
			}
		}
		
		if(cnt == N) {
			System.out.println(cnt);
		} else {
			System.out.println(-1);
		}
	}
}
0