結果

問題 No.406 鴨等間隔の法則
ユーザー yagi2yagi2
提出日時 2017-04-17 10:37:55
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,168 bytes
コンパイル時間 2,546 ms
コンパイル使用メモリ 79,464 KB
実行使用メモリ 60,660 KB
最終ジャッジ日時 2024-04-25 01:04:03
合計ジャッジ時間 17,424 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 748 ms
56,352 KB
testcase_01 AC 132 ms
40,444 KB
testcase_02 AC 121 ms
41,160 KB
testcase_03 AC 130 ms
41,316 KB
testcase_04 AC 1,132 ms
58,080 KB
testcase_05 AC 837 ms
49,660 KB
testcase_06 AC 556 ms
49,376 KB
testcase_07 AC 632 ms
49,656 KB
testcase_08 AC 1,009 ms
60,660 KB
testcase_09 AC 495 ms
51,772 KB
testcase_10 AC 941 ms
56,584 KB
testcase_11 AC 1,268 ms
57,848 KB
testcase_12 AC 1,175 ms
57,036 KB
testcase_13 AC 679 ms
52,404 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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()));
        }

        boolean kamoFlag = true;
        for (int i = 0; i < N; i++) {
            List<Long> tmpKamos = new ArrayList<>(kamos);
            tmpKamos.remove(i);
            if (tmpKamos.contains(kamos.get(i))) {
                kamoFlag = false;
                break;
            }
        }

        if (!kamoFlag) {
            System.out.println("NO");
        } else {
            Collections.sort(kamos);

            long distance = kamos.get(1) - kamos.get(0);
            for (int i = 1; i < N - 1; i++) {
                if (kamos.get(i+1) - kamos.get(i) != distance) {
                    kamoFlag = false;
                    break;
                }
            }

            if (!kamoFlag) {
                System.out.println("NO");
            } else {
                System.out.println("YES");
            }
        }
    }
}
0