結果

問題 No.390 最長の数列
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-07 01:00:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,871 ms / 5,000 ms
コード長 333 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 10,716 KB
実行使用メモリ 25,720 KB
最終ジャッジ日時 2023-09-08 18:07:21
合計ジャッジ時間 7,019 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
23,784 KB
testcase_01 AC 113 ms
23,788 KB
testcase_02 AC 147 ms
23,400 KB
testcase_03 AC 125 ms
23,744 KB
testcase_04 AC 151 ms
23,604 KB
testcase_05 AC 167 ms
25,636 KB
testcase_06 AC 1,871 ms
25,596 KB
testcase_07 AC 142 ms
23,616 KB
testcase_08 AC 109 ms
23,784 KB
testcase_09 AC 141 ms
23,600 KB
testcase_10 AC 271 ms
25,576 KB
testcase_11 AC 286 ms
25,720 KB
testcase_12 AC 282 ms
25,576 KB
testcase_13 AC 274 ms
25,172 KB
testcase_14 AC 1,237 ms
25,628 KB
testcase_15 AC 107 ms
23,696 KB
testcase_16 AC 82 ms
23,704 KB
testcase_17 AC 89 ms
24,144 KB
testcase_18 AC 93 ms
24,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
m = 10**6+1
s = [False]*m
for i in map(int, input().split()):
    s[i] = True
memo = [0]*m
def dfs(i):
    if not memo[i]:
        memo[i] = 1
        for j in range(i+i, m, i):
            if s[j]:
                memo[i] = max(memo[i], 1 + dfs(j))
    return memo[i]
print(max(dfs(i) for i in range(1, m) if s[i]))
0