結果

問題 No.406 鴨等間隔の法則
ユーザー yagi2yagi2
提出日時 2017-04-17 10:50:15
言語 Java19
(openjdk 21)
結果
AC  
実行時間 706 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 76,496 KB
実行使用メモリ 70,696 KB
最終ジャッジ日時 2023-09-21 18:29:42
合計ジャッジ時間 18,340 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 435 ms
61,960 KB
testcase_01 AC 111 ms
55,904 KB
testcase_02 AC 113 ms
55,808 KB
testcase_03 AC 114 ms
55,784 KB
testcase_04 AC 644 ms
66,024 KB
testcase_05 AC 401 ms
61,824 KB
testcase_06 AC 416 ms
61,492 KB
testcase_07 AC 412 ms
61,656 KB
testcase_08 AC 652 ms
66,288 KB
testcase_09 AC 690 ms
68,244 KB
testcase_10 AC 440 ms
61,908 KB
testcase_11 AC 623 ms
65,600 KB
testcase_12 AC 497 ms
63,604 KB
testcase_13 AC 467 ms
61,552 KB
testcase_14 AC 636 ms
66,852 KB
testcase_15 AC 190 ms
58,564 KB
testcase_16 AC 227 ms
60,068 KB
testcase_17 AC 189 ms
58,612 KB
testcase_18 AC 213 ms
59,016 KB
testcase_19 AC 246 ms
60,020 KB
testcase_20 AC 268 ms
61,492 KB
testcase_21 AC 269 ms
60,424 KB
testcase_22 AC 327 ms
61,592 KB
testcase_23 AC 509 ms
63,840 KB
testcase_24 AC 616 ms
64,244 KB
testcase_25 AC 694 ms
70,012 KB
testcase_26 AC 702 ms
70,696 KB
testcase_27 AC 557 ms
63,376 KB
testcase_28 AC 557 ms
65,572 KB
testcase_29 AC 706 ms
70,272 KB
testcase_30 AC 700 ms
68,516 KB
testcase_31 AC 672 ms
64,784 KB
権限があれば一括ダウンロードができます

ソースコード

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