結果

問題 No.390 最長の数列
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-07 08:54:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 273 ms / 5,000 ms
コード長 310 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 100,548 KB
最終ジャッジ日時 2023-09-08 18:11:36
合計ジャッジ時間 3,724 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
91,532 KB
testcase_01 AC 96 ms
91,372 KB
testcase_02 AC 103 ms
91,288 KB
testcase_03 AC 96 ms
91,552 KB
testcase_04 AC 97 ms
91,604 KB
testcase_05 AC 113 ms
100,096 KB
testcase_06 AC 273 ms
100,304 KB
testcase_07 AC 94 ms
91,452 KB
testcase_08 AC 90 ms
91,272 KB
testcase_09 AC 95 ms
91,128 KB
testcase_10 AC 151 ms
100,548 KB
testcase_11 AC 150 ms
100,544 KB
testcase_12 AC 162 ms
99,952 KB
testcase_13 AC 127 ms
97,984 KB
testcase_14 AC 185 ms
99,852 KB
testcase_15 AC 91 ms
91,124 KB
testcase_16 AC 96 ms
91,440 KB
testcase_17 AC 101 ms
92,168 KB
testcase_18 AC 101 ms
92,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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