結果

問題 No.185 和風
ユーザー yagi2yagi2
提出日時 2017-04-21 17:29:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 81,608 KB
実行使用メモリ 56,888 KB
最終ジャッジ日時 2023-09-27 11:01:02
合計ジャッジ時間 3,881 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
56,888 KB
testcase_01 AC 167 ms
56,252 KB
testcase_02 WA -
testcase_03 AC 162 ms
56,248 KB
testcase_04 AC 157 ms
56,172 KB
testcase_05 AC 120 ms
55,992 KB
testcase_06 AC 166 ms
56,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int N = Integer.parseInt(sc.next());

        Map<Long, Long> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            long X = Long.parseLong(sc.next());
            long Y = Long.parseLong(sc.next());

            if (Y - X > 0) {
                if (!map.containsKey(Y-X)) map.put(Y-X, (long) 0);
                map.put(Y-X, map.get(Y-X)+1);
            }
        }
        if (map.size() == 1) {
            map.forEach((aLong, aLong2) -> System.out.println(aLong));
        } else {
            System.out.println("-1");
        }
    }
}
0