結果

問題 No.390 最長の数列
ユーザー irumo8202irumo8202
提出日時 2022-01-22 18:37:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 590 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 27,068 KB
最終ジャッジ日時 2023-08-18 13:03:51
合計ジャッジ時間 6,818 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,348 KB
testcase_01 AC 17 ms
7,864 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 15 ms
7,792 KB
testcase_04 AC 16 ms
7,820 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
X = list(map(int, input().split()))
X.sort()


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


dp = [0] * (X[-1] + 1)

for i in range(N):
    x = X[i]
    x_div = make_divisors(x)
    tmp = 0
    for xd in x_div:
        tmp = max(tmp, dp[xd])
    dp[x] = tmp + 1

ans = 0
for val in dp:
    ans = max(ans, val)

print(ans)
0