結果

問題 No.390 最長の数列
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-07-12 13:04:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,751 ms / 5,000 ms
コード長 692 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 97,964 KB
最終ジャッジ日時 2024-04-10 09:07:09
合計ジャッジ時間 15,719 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
88,324 KB
testcase_01 AC 104 ms
88,612 KB
testcase_02 AC 98 ms
88,808 KB
testcase_03 AC 103 ms
88,260 KB
testcase_04 AC 100 ms
88,684 KB
testcase_05 AC 2,751 ms
97,328 KB
testcase_06 AC 2,129 ms
97,612 KB
testcase_07 AC 103 ms
88,524 KB
testcase_08 AC 106 ms
88,708 KB
testcase_09 AC 104 ms
88,864 KB
testcase_10 AC 2,005 ms
97,740 KB
testcase_11 AC 1,999 ms
97,964 KB
testcase_12 AC 1,996 ms
97,500 KB
testcase_13 AC 1,387 ms
97,336 KB
testcase_14 AC 871 ms
97,600 KB
testcase_15 AC 104 ms
88,504 KB
testcase_16 AC 109 ms
88,396 KB
testcase_17 AC 205 ms
91,072 KB
testcase_18 AC 256 ms
91,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import array
import math


MAX_X = 10 ** 6


def divisors_without_self(n, typecode="L"):
    ds = array.array(typecode)
    if n != 1:
        for i in range(1, math.floor(math.sqrt(n)) + 1):
            r, m = divmod(n, i)
            if m == 0:
                ds.append(i)
                if i != 1 and i != r:
                    ds.append(r)
    return ds


def main():
    _ = input()
    xs = sorted(map(int, input().split()))
    dp = array.array("L", (0 for _ in range(MAX_X + 1)))
    for x in xs:
        dp[x] = 1
        for y in divisors_without_self(x):
            dp[x] = max(dp[x], dp[y] + 1)
    print(max(dp))


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