結果

問題 No.2218 Multiple LIS
ユーザー FromBooskaFromBooska
提出日時 2023-02-18 09:55:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 817 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 54,716 KB
最終ジャッジ日時 2023-09-27 04:03:13
合計ジャッジ時間 16,878 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,628 KB
testcase_01 AC 16 ms
8,576 KB
testcase_02 AC 17 ms
8,504 KB
testcase_03 AC 17 ms
8,500 KB
testcase_04 AC 16 ms
8,484 KB
testcase_05 AC 17 ms
8,452 KB
testcase_06 AC 17 ms
8,528 KB
testcase_07 AC 17 ms
8,468 KB
testcase_08 AC 17 ms
8,492 KB
testcase_09 AC 16 ms
8,596 KB
testcase_10 AC 17 ms
8,448 KB
testcase_11 AC 16 ms
8,592 KB
testcase_12 AC 19 ms
8,716 KB
testcase_13 AC 29 ms
8,948 KB
testcase_14 AC 24 ms
8,772 KB
testcase_15 AC 24 ms
8,796 KB
testcase_16 AC 18 ms
8,560 KB
testcase_17 AC 30 ms
8,960 KB
testcase_18 AC 17 ms
8,588 KB
testcase_19 AC 18 ms
8,500 KB
testcase_20 AC 29 ms
8,788 KB
testcase_21 AC 48 ms
13,856 KB
testcase_22 AC 289 ms
32,008 KB
testcase_23 AC 534 ms
39,884 KB
testcase_24 AC 171 ms
26,760 KB
testcase_25 AC 602 ms
41,140 KB
testcase_26 AC 1,262 ms
53,888 KB
testcase_27 AC 1,349 ms
54,716 KB
testcase_28 AC 1,216 ms
53,796 KB
testcase_29 AC 1,034 ms
52,748 KB
testcase_30 AC 1,231 ms
53,992 KB
testcase_31 TLE -
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
for i in range(N):
    num = A[i]
    mx = 1
    for j in div[i]:
        mx = max(mx, dp[j]+1)
    dp[i] = mx
#print(dp)

ans = max(dp)
print(ans)
0