結果

問題 No.2218 Multiple LIS
ユーザー ShirotsumeShirotsume
提出日時 2023-02-14 07:26:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 86,516 KB
実行使用メモリ 78,680 KB
最終ジャッジ日時 2023-09-23 17:27:36
合計ジャッジ時間 10,337 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,624 KB
testcase_01 AC 93 ms
71,532 KB
testcase_02 AC 97 ms
71,220 KB
testcase_03 AC 93 ms
71,376 KB
testcase_04 AC 93 ms
71,304 KB
testcase_05 AC 93 ms
71,444 KB
testcase_06 AC 93 ms
71,304 KB
testcase_07 WA -
testcase_08 AC 93 ms
71,420 KB
testcase_09 AC 92 ms
71,008 KB
testcase_10 AC 92 ms
71,584 KB
testcase_11 AC 98 ms
76,620 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 TLE -
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 #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()

a = li()

#ふつうのLISと同様にdpすればよい?
#無理そう

#dp[i] = i番目が最後尾であるときの最大値とすると,iを見るときにはa[i]の約数の部分(最大値)だけ見ればよい

dp = [-inf] * (n + 1)
dp[0] = 1
maxi = [-inf] * (max(a) + 1)

for idx, v in enumerate(a):
    div = []
    v2 = v
    for i in range(1, v2 + 1):
        if i * i > v2:
            continue
        if v2 % i == 0:
            div.append(i)
            div.append(v2 // i)
    for v2 in div:
        dp[idx] = max(dp[idx], maxi[v2] + 1)
    maxi[v] = dp[idx]

print(max(dp))
0