結果

問題 No.406 鴨等間隔の法則
ユーザー yagi2
提出日時 2017-04-17 10:50:15
言語 Java
(openjdk 23)
結果
AC  
実行時間 675 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 78,280 KB
実行使用メモリ 69,680 KB
最終ジャッジ日時 2024-07-07 12:05:25
合計ジャッジ時間 17,581 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

        int N = Integer.parseInt(sc.next());
        List<Long> kamos = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            kamos.add(Long.parseLong(sc.next()));
        }

        Collections.sort(kamos);

        List<Long> S = new ArrayList<>();
        for (int i = 0; i < N - 1; i++) {
            S.add(kamos.get(i+1) - kamos.get(i));
        }

        if (S.contains(new Long("0"))) {
            System.out.println("NO");
        } else {
            Set<Long> set = new HashSet<>(S);
            List<Long> d = new ArrayList<>(set);

            if (d.size() == 1) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}
0