結果

問題 No.2218 Multiple LIS
ユーザー FromBooskaFromBooska
提出日時 2023-02-18 08:49:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 553,792 KB
最終ジャッジ日時 2023-09-27 03:25:15
合計ジャッジ時間 16,493 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
71,832 KB
testcase_01 AC 115 ms
71,532 KB
testcase_02 AC 112 ms
71,756 KB
testcase_03 AC 108 ms
71,724 KB
testcase_04 AC 105 ms
71,784 KB
testcase_05 AC 113 ms
71,704 KB
testcase_06 AC 112 ms
71,692 KB
testcase_07 AC 112 ms
71,752 KB
testcase_08 AC 112 ms
71,736 KB
testcase_09 AC 108 ms
71,696 KB
testcase_10 AC 114 ms
71,660 KB
testcase_11 AC 111 ms
71,324 KB
testcase_12 AC 121 ms
77,820 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 114 ms
71,752 KB
testcase_19 AC 117 ms
77,576 KB
testcase_20 WA -
testcase_21 AC 155 ms
82,124 KB
testcase_22 WA -
testcase_23 AC 500 ms
107,196 KB
testcase_24 AC 240 ms
99,372 KB
testcase_25 AC 565 ms
110,384 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)

dp = [0]*(N)
dp[0] = 1
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, dp[j]+1)
        mx_dic[num] = mx
    dp[i] = mx_dic[num]
#print(dp)

ans = max(dp)
print(ans)
0