結果

問題 No.2218 Multiple LIS
ユーザー ntudantuda
提出日時 2023-02-20 20:30:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 917 ms / 3,000 ms
コード長 694 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 86,608 KB
実行使用メモリ 156,636 KB
最終ジャッジ日時 2023-09-28 16:25:17
合計ジャッジ時間 13,966 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
72,708 KB
testcase_01 AC 115 ms
72,264 KB
testcase_02 AC 112 ms
72,492 KB
testcase_03 AC 111 ms
72,600 KB
testcase_04 AC 111 ms
72,540 KB
testcase_05 AC 111 ms
72,484 KB
testcase_06 AC 111 ms
72,372 KB
testcase_07 AC 109 ms
72,388 KB
testcase_08 AC 108 ms
72,336 KB
testcase_09 AC 109 ms
72,220 KB
testcase_10 AC 110 ms
72,436 KB
testcase_11 AC 109 ms
72,420 KB
testcase_12 AC 117 ms
77,148 KB
testcase_13 AC 129 ms
77,496 KB
testcase_14 AC 119 ms
77,276 KB
testcase_15 AC 116 ms
77,252 KB
testcase_16 AC 108 ms
72,380 KB
testcase_17 AC 124 ms
77,660 KB
testcase_18 AC 106 ms
72,480 KB
testcase_19 AC 110 ms
72,544 KB
testcase_20 AC 124 ms
77,512 KB
testcase_21 AC 185 ms
84,928 KB
testcase_22 AC 459 ms
113,364 KB
testcase_23 AC 659 ms
141,492 KB
testcase_24 AC 266 ms
92,716 KB
testcase_25 AC 732 ms
141,704 KB
testcase_26 AC 916 ms
154,884 KB
testcase_27 AC 909 ms
156,636 KB
testcase_28 AC 910 ms
154,444 KB
testcase_29 AC 905 ms
156,284 KB
testcase_30 AC 917 ms
156,032 KB
testcase_31 AC 188 ms
94,684 KB
testcase_32 AC 187 ms
94,684 KB
testcase_33 AC 188 ms
94,644 KB
testcase_34 AC 186 ms
94,632 KB
testcase_35 AC 187 ms
94,664 KB
testcase_36 AC 143 ms
90,512 KB
testcase_37 AC 206 ms
99,120 KB
testcase_38 AC 109 ms
72,376 KB
testcase_39 AC 106 ms
72,592 KB
testcase_40 AC 191 ms
96,352 KB
testcase_41 AC 193 ms
96,368 KB
権限があれば一括ダウンロードができます

ソースコード

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 = [set() 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].add(a)

print(max(E))
0