結果

問題 No.2218 Multiple LIS
ユーザー FromBooskaFromBooska
提出日時 2023-02-18 08:46:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 773 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 637,440 KB
最終ジャッジ日時 2023-09-27 03:22:21
合計ジャッジ時間 14,986 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,852 KB
testcase_01 AC 92 ms
71,752 KB
testcase_02 AC 92 ms
71,608 KB
testcase_03 AC 92 ms
71,684 KB
testcase_04 AC 93 ms
71,756 KB
testcase_05 AC 91 ms
71,776 KB
testcase_06 AC 93 ms
71,680 KB
testcase_07 AC 93 ms
71,676 KB
testcase_08 AC 93 ms
71,356 KB
testcase_09 AC 93 ms
71,660 KB
testcase_10 AC 93 ms
71,604 KB
testcase_11 AC 91 ms
71,248 KB
testcase_12 AC 108 ms
77,584 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 92 ms
71,556 KB
testcase_19 AC 99 ms
77,640 KB
testcase_20 WA -
testcase_21 AC 127 ms
82,216 KB
testcase_22 WA -
testcase_23 AC 357 ms
106,676 KB
testcase_24 AC 192 ms
99,388 KB
testcase_25 AC 416 ms
109,080 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:
        temp = 0
        for j in div[i]:
            temp = max(temp, mx_dic[A[j]])
        mx_dic[num] = temp+1

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



0