結果

問題 No.2218 Multiple LIS
ユーザー rlangevinrlangevin
提出日時 2023-02-17 21:43:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 587 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 86,676 KB
実行使用メモリ 237,364 KB
最終ジャッジ日時 2023-09-26 18:57:41
合計ジャッジ時間 8,028 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
76,028 KB
testcase_01 AC 92 ms
71,476 KB
testcase_02 AC 92 ms
71,444 KB
testcase_03 AC 91 ms
71,404 KB
testcase_04 AC 93 ms
71,284 KB
testcase_05 AC 90 ms
71,228 KB
testcase_06 AC 90 ms
71,268 KB
testcase_07 AC 89 ms
71,228 KB
testcase_08 AC 90 ms
71,404 KB
testcase_09 AC 89 ms
71,288 KB
testcase_10 AC 91 ms
71,252 KB
testcase_11 AC 91 ms
71,472 KB
testcase_12 AC 120 ms
77,360 KB
testcase_13 AC 125 ms
77,336 KB
testcase_14 AC 123 ms
77,460 KB
testcase_15 AC 125 ms
77,364 KB
testcase_16 AC 106 ms
77,332 KB
testcase_17 AC 125 ms
77,612 KB
testcase_18 AC 101 ms
76,808 KB
testcase_19 AC 105 ms
77,212 KB
testcase_20 AC 123 ms
77,376 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

def div(n):
    if n <= 0:
        return []
    S = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            S.add(i)
            S.add(n // i)
        i += 1
    return list(S)

N = int(input())
A = list(map(int, input().split()))
pre = defaultdict(lambda : -10)
pre[1] = 0
for a in A:
    dp = defaultdict(lambda : -10)
    for d in div(a):
        dp[a] = max(dp[a], pre[d] + 1)
    for k, v in pre.items():
        dp[k] = max(dp[k], v)
        
    dp, pre = pre, dp

ans = 0
for k, v in pre.items():
    ans = max(ans, v)
    
print(ans)
0