結果

問題 No.2218 Multiple LIS
ユーザー ntudantuda
提出日時 2023-02-20 17:03:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 694 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 143,480 KB
最終ジャッジ日時 2023-09-28 14:21:42
合計ジャッジ時間 15,433 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
72,240 KB
testcase_01 AC 114 ms
72,532 KB
testcase_02 AC 109 ms
72,248 KB
testcase_03 AC 108 ms
72,416 KB
testcase_04 AC 109 ms
72,268 KB
testcase_05 AC 108 ms
72,348 KB
testcase_06 AC 109 ms
72,264 KB
testcase_07 AC 114 ms
72,340 KB
testcase_08 AC 108 ms
72,356 KB
testcase_09 AC 108 ms
72,348 KB
testcase_10 AC 108 ms
72,336 KB
testcase_11 AC 108 ms
72,312 KB
testcase_12 AC 116 ms
77,144 KB
testcase_13 AC 124 ms
77,444 KB
testcase_14 AC 123 ms
77,504 KB
testcase_15 AC 123 ms
77,464 KB
testcase_16 AC 110 ms
72,496 KB
testcase_17 AC 124 ms
77,588 KB
testcase_18 AC 111 ms
72,432 KB
testcase_19 AC 110 ms
72,276 KB
testcase_20 AC 125 ms
77,604 KB
testcase_21 AC 196 ms
84,028 KB
testcase_22 AC 389 ms
102,940 KB
testcase_23 AC 522 ms
114,588 KB
testcase_24 AC 243 ms
88,412 KB
testcase_25 AC 583 ms
123,204 KB
testcase_26 AC 734 ms
143,480 KB
testcase_27 AC 733 ms
135,620 KB
testcase_28 AC 718 ms
135,340 KB
testcase_29 AC 730 ms
135,172 KB
testcase_30 AC 710 ms
135,152 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 #

from functools import lru_cache
@lru_cache(maxsize=100000)

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


N = int(input())
A = list(map(int, input().split()))
maxa = max(A)
C = [[] for _ in range(maxa + 1)]
E = [0] * (maxa + 1)
for a in reversed(A):
    tmp = 0
    if C[a]:
        for x in C[a]:
            tmp = max(tmp, E[x])

    E[a] = max(E[a], tmp + 1)

    D = make_divisors(a)
    for d in D:
        C[d].append(a)

print(max(E))
0