結果

問題 No.2218 Multiple LIS
ユーザー ntudantuda
提出日時 2023-02-20 20:12:00
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 694 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 131,000 KB
最終ジャッジ日時 2023-09-28 16:15:50
合計ジャッジ時間 15,406 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
76,960 KB
testcase_01 AC 119 ms
72,196 KB
testcase_02 AC 114 ms
72,360 KB
testcase_03 AC 115 ms
72,472 KB
testcase_04 AC 111 ms
72,464 KB
testcase_05 AC 114 ms
72,492 KB
testcase_06 AC 117 ms
72,384 KB
testcase_07 AC 117 ms
72,428 KB
testcase_08 AC 116 ms
72,440 KB
testcase_09 AC 116 ms
72,608 KB
testcase_10 AC 117 ms
72,684 KB
testcase_11 AC 115 ms
72,588 KB
testcase_12 AC 128 ms
77,164 KB
testcase_13 AC 131 ms
77,664 KB
testcase_14 AC 127 ms
77,592 KB
testcase_15 AC 130 ms
77,672 KB
testcase_16 AC 118 ms
72,276 KB
testcase_17 AC 130 ms
77,544 KB
testcase_18 AC 116 ms
72,416 KB
testcase_19 AC 116 ms
72,420 KB
testcase_20 AC 130 ms
77,684 KB
testcase_21 AC 191 ms
84,052 KB
testcase_22 AC 404 ms
99,088 KB
testcase_23 AC 564 ms
119,024 KB
testcase_24 AC 260 ms
89,948 KB
testcase_25 AC 610 ms
118,720 KB
testcase_26 AC 769 ms
130,504 KB
testcase_27 AC 774 ms
130,656 KB
testcase_28 AC 788 ms
129,804 KB
testcase_29 AC 769 ms
131,000 KB
testcase_30 AC 781 ms
130,636 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):
    divisors = []  #必要に応じてsetにしても良いかも
    i = 1
    while i ** 2 <= n:
        if n % i == 0:
            divisors.append(i)
            if i ** 2 != n:
                divisors.append(n//i)
        i += 1
    #divisors.sort()
    return divisors


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