結果

問題 No.390 最長の数列
ユーザー brthyyjpbrthyyjp
提出日時 2021-12-16 17:15:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,770 ms / 5,000 ms
コード長 497 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 100,124 KB
最終ジャッジ日時 2023-10-11 15:39:12
合計ジャッジ時間 11,047 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,336 KB
testcase_01 AC 76 ms
71,512 KB
testcase_02 AC 76 ms
71,592 KB
testcase_03 AC 80 ms
71,688 KB
testcase_04 AC 76 ms
71,620 KB
testcase_05 AC 1,770 ms
99,764 KB
testcase_06 AC 1,120 ms
99,476 KB
testcase_07 AC 77 ms
71,292 KB
testcase_08 AC 85 ms
82,900 KB
testcase_09 AC 85 ms
82,988 KB
testcase_10 AC 1,240 ms
100,108 KB
testcase_11 AC 1,231 ms
99,964 KB
testcase_12 AC 1,249 ms
100,124 KB
testcase_13 AC 902 ms
95,776 KB
testcase_14 AC 500 ms
92,264 KB
testcase_15 AC 78 ms
75,392 KB
testcase_16 AC 85 ms
83,604 KB
testcase_17 AC 150 ms
84,888 KB
testcase_18 AC 184 ms
85,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

dp = [0]*(max(X)+1)
for x in X:
    if x == 1:
        dp[1] = 1
        continue
    d = make_divisors(x)
    for i in d:
        if i == x:
            continue
        dp[x] = max(dp[i]+1, dp[x])
print(max(dp))
0