結果

問題 No.406 鴨等間隔の法則
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-08-03 17:23:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 91,904 KB
最終ジャッジ日時 2023-09-21 17:40:06
合計ジャッジ時間 4,336 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
80,748 KB
testcase_01 AC 68 ms
71,500 KB
testcase_02 AC 72 ms
71,288 KB
testcase_03 AC 68 ms
71,268 KB
testcase_04 AC 87 ms
88,756 KB
testcase_05 AC 80 ms
79,364 KB
testcase_06 AC 77 ms
79,444 KB
testcase_07 AC 77 ms
79,940 KB
testcase_08 AC 86 ms
88,568 KB
testcase_09 AC 90 ms
90,404 KB
testcase_10 AC 78 ms
80,916 KB
testcase_11 AC 86 ms
86,776 KB
testcase_12 AC 79 ms
81,796 KB
testcase_13 AC 80 ms
81,860 KB
testcase_14 AC 93 ms
89,692 KB
testcase_15 AC 73 ms
75,840 KB
testcase_16 AC 72 ms
75,960 KB
testcase_17 AC 71 ms
75,824 KB
testcase_18 AC 73 ms
75,808 KB
testcase_19 AC 75 ms
76,208 KB
testcase_20 AC 77 ms
76,208 KB
testcase_21 AC 73 ms
76,068 KB
testcase_22 AC 78 ms
77,876 KB
testcase_23 AC 80 ms
82,780 KB
testcase_24 AC 89 ms
87,816 KB
testcase_25 AC 90 ms
90,624 KB
testcase_26 AC 96 ms
91,904 KB
testcase_27 AC 88 ms
90,636 KB
testcase_28 AC 89 ms
90,544 KB
testcase_29 AC 96 ms
91,792 KB
testcase_30 AC 96 ms
91,516 KB
testcase_31 AC 89 ms
90,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3
# btkさんのO(N)解 http://yukicoder.me/submissions/108107 を踏まえて


def validate(n, xs):
    x_max = max(xs)
    x_min = min(xs)
    # 数列の「幅」を求める
    l = x_max - x_min
    # 「間の数」はN - 1個
    # lがこれで割り切れない or lが0ならば不適
    d, m = divmod(l, n - 1)
    if m > 0 or l == 0:
        return False
    # ソート済みの列は y_i = y_0 + i dと表される
    # ここでy_0 = x_min
    # x_iの各要素がその一つ一つに対応している必要がある
    counter = [0 for _ in range(n)]
    for x in xs:
        i, m = divmod(x - x_min, d)
        if m > 0:
            return False
        counter[i] += 1
    return n == sum(counter)


def main():
    n = int(input())
    xs = list(map(int, input().split()))
    print("YES" if validate(n, xs) else "NO")


if __name__ == '__main__':
    main()
0