結果

問題 No.185 和風
ユーザー yagi2
提出日時 2017-04-21 17:29:31
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 2,600 ms
コンパイル使用メモリ 87,768 KB
実行使用メモリ 42,300 KB
最終ジャッジ日時 2024-07-20 05:10:01
合計ジャッジ時間 4,361 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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