結果

問題 No.2218 Multiple LIS
ユーザー FromBooskaFromBooska
提出日時 2023-02-18 10:10:05
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 838 bytes
コンパイル時間 758 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 638,016 KB
最終ジャッジ日時 2023-09-27 04:14:12
合計ジャッジ時間 13,553 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,872 KB
testcase_01 AC 90 ms
71,700 KB
testcase_02 AC 88 ms
71,712 KB
testcase_03 AC 91 ms
71,736 KB
testcase_04 AC 91 ms
71,632 KB
testcase_05 AC 89 ms
71,460 KB
testcase_06 AC 91 ms
71,584 KB
testcase_07 AC 89 ms
71,452 KB
testcase_08 AC 90 ms
71,880 KB
testcase_09 AC 91 ms
71,720 KB
testcase_10 AC 90 ms
71,872 KB
testcase_11 AC 89 ms
71,824 KB
testcase_12 AC 105 ms
77,696 KB
testcase_13 AC 106 ms
78,288 KB
testcase_14 AC 110 ms
78,120 KB
testcase_15 AC 106 ms
77,932 KB
testcase_16 AC 100 ms
77,364 KB
testcase_17 AC 108 ms
77,968 KB
testcase_18 AC 91 ms
71,696 KB
testcase_19 AC 99 ms
77,652 KB
testcase_20 AC 110 ms
77,800 KB
testcase_21 AC 149 ms
82,208 KB
testcase_22 AC 229 ms
97,748 KB
testcase_23 AC 337 ms
104,388 KB
testcase_24 AC 187 ms
99,312 KB
testcase_25 AC 386 ms
105,456 KB
testcase_26 AC 728 ms
113,428 KB
testcase_27 AC 822 ms
116,436 KB
testcase_28 AC 715 ms
114,272 KB
testcase_29 AC 621 ms
112,884 KB
testcase_30 AC 786 ms
113,416 KB
testcase_31 MLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 先頭からdp的辞書でやるか
# 辞書は失敗する、辞書が上書きされて後で参照した時に値が変わってしまっている
# dp的にやる
# 倍数約数で行ったり来たりするので間に合わない気がする

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

from collections import defaultdict
A_position = defaultdict(list)
for i in range(N):
    A_position[A[i]].append(i)
    
#print(A_position)

div = defaultdict(list)
maxA = max(A)
for i in range(N):
    for q in range(A[i], maxA+1, A[i]):
        for r in A_position[q]:
            if r > i:
                div[r].append(i)

#print(div)

dp = [0]*(N)
dp[0] = 1
ans = 0
for i in range(N):
    num = A[i]
    mx = 1
    for j in div[i]:
        mx = max(mx, dp[j]+1)
    dp[i] = mx
    ans = max(ans, dp[i])
#print(dp)

print(ans)


0