結果

問題 No.2218 Multiple LIS
ユーザー FromBooskaFromBooska
提出日時 2023-02-18 08:35:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 778 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 734,316 KB
最終ジャッジ日時 2023-09-27 03:14:59
合計ジャッジ時間 12,889 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
75,856 KB
testcase_01 AC 84 ms
71,344 KB
testcase_02 AC 87 ms
71,452 KB
testcase_03 AC 82 ms
71,564 KB
testcase_04 AC 88 ms
71,696 KB
testcase_05 AC 83 ms
71,308 KB
testcase_06 AC 82 ms
71,656 KB
testcase_07 AC 85 ms
71,304 KB
testcase_08 AC 84 ms
71,500 KB
testcase_09 AC 83 ms
71,684 KB
testcase_10 AC 88 ms
71,520 KB
testcase_11 AC 84 ms
71,668 KB
testcase_12 AC 94 ms
77,544 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 87 ms
71,324 KB
testcase_19 AC 91 ms
77,336 KB
testcase_20 WA -
testcase_21 AC 119 ms
81,900 KB
testcase_22 WA -
testcase_23 AC 313 ms
106,212 KB
testcase_24 AC 175 ms
99,300 KB
testcase_25 AC 353 ms
109,748 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
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的辞書でやるか
# 倍数約数で行ったり来たりするので間に合わない気がする

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)

mx_dic = {}
for i in range(N):
    num = A[i]
    if num in mx_dic:
        mx_dic[num] += 1
    else:
        mx = 1
        for j in div[i]:
            mx = max(mx, mx_dic[A[j]]+1)
        mx_dic[num] = mx

#print(mx_dic)

ans = max(mx_dic.values())
print(ans)
0