結果

問題 No.390 最長の数列
ユーザー ronpooronpoo
提出日時 2023-08-29 11:00:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 216 ms / 5,000 ms
コード長 304 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 99,344 KB
最終ジャッジ日時 2023-08-29 11:00:40
合計ジャッジ時間 3,892 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,580 KB
testcase_01 AC 69 ms
71,332 KB
testcase_02 AC 70 ms
71,420 KB
testcase_03 AC 71 ms
71,252 KB
testcase_04 AC 69 ms
71,300 KB
testcase_05 AC 124 ms
99,188 KB
testcase_06 AC 216 ms
98,592 KB
testcase_07 AC 70 ms
71,240 KB
testcase_08 AC 77 ms
82,840 KB
testcase_09 AC 80 ms
83,616 KB
testcase_10 AC 140 ms
99,080 KB
testcase_11 AC 137 ms
99,200 KB
testcase_12 AC 136 ms
99,344 KB
testcase_13 AC 116 ms
94,984 KB
testcase_14 AC 128 ms
92,036 KB
testcase_15 AC 72 ms
75,196 KB
testcase_16 AC 75 ms
82,988 KB
testcase_17 AC 87 ms
84,456 KB
testcase_18 AC 87 ms
84,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
x = list(map(int, input().split()))

xma = max(x)
x.sort()
dp = [-1] * (xma+1)
for i in range(N):
    dp[x[i]] = 1

for i in range(N):
    v = x[i]    
    for j in range(2*v, xma+1, v):
        if dp[j] != -1:
            dp[j] = max(dp[j], dp[v] + 1)

ans = max(dp)        
print(ans)
0