結果

問題 No.2218 Multiple LIS
ユーザー ikomaikoma
提出日時 2023-02-17 22:24:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 305 ms / 3,000 ms
コード長 1,181 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 92,280 KB
最終ジャッジ日時 2023-09-26 19:39:33
合計ジャッジ時間 8,178 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
77,416 KB
testcase_01 AC 85 ms
77,416 KB
testcase_02 AC 84 ms
77,280 KB
testcase_03 AC 82 ms
77,232 KB
testcase_04 AC 85 ms
77,400 KB
testcase_05 AC 84 ms
77,580 KB
testcase_06 AC 84 ms
77,144 KB
testcase_07 AC 82 ms
77,460 KB
testcase_08 AC 83 ms
77,364 KB
testcase_09 AC 83 ms
77,464 KB
testcase_10 AC 83 ms
77,396 KB
testcase_11 AC 82 ms
77,256 KB
testcase_12 AC 90 ms
78,232 KB
testcase_13 AC 99 ms
78,516 KB
testcase_14 AC 102 ms
78,344 KB
testcase_15 AC 102 ms
79,100 KB
testcase_16 AC 88 ms
77,524 KB
testcase_17 AC 103 ms
78,344 KB
testcase_18 AC 84 ms
77,288 KB
testcase_19 AC 86 ms
77,832 KB
testcase_20 AC 101 ms
78,328 KB
testcase_21 AC 126 ms
79,232 KB
testcase_22 AC 185 ms
83,316 KB
testcase_23 AC 214 ms
86,100 KB
testcase_24 AC 141 ms
79,536 KB
testcase_25 AC 237 ms
87,084 KB
testcase_26 AC 286 ms
91,784 KB
testcase_27 AC 284 ms
91,924 KB
testcase_28 AC 287 ms
91,976 KB
testcase_29 AC 280 ms
91,936 KB
testcase_30 AC 279 ms
92,100 KB
testcase_31 AC 193 ms
92,172 KB
testcase_32 AC 198 ms
92,108 KB
testcase_33 AC 201 ms
91,980 KB
testcase_34 AC 199 ms
92,236 KB
testcase_35 AC 194 ms
91,432 KB
testcase_36 AC 109 ms
90,796 KB
testcase_37 AC 305 ms
92,280 KB
testcase_38 AC 80 ms
77,684 KB
testcase_39 AC 82 ms
77,424 KB
testcase_40 AC 235 ms
91,760 KB
testcase_41 AC 236 ms
91,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
class tmp:
    def __init__(self, n_max:int=10**6):
        self.sieve = self.pre_factorization(n_max)
    def pre_factorization(self, n_max:int):
        sieve = [i for i in range(n_max+1)]
        p = 2
        while p*p <= n_max:
            if sieve[p] == p:
                for q in range(2*p,n_max+1,p):
                    if sieve[q] == q:
                        sieve[q] = p
            p += 1
        return sieve
    def factorization(self, n:int):
        tmp = {}
        while n > 1:
            i=self.sieve[n]
            tmp[i]=tmp.get(i,0)+1
            n //= self.sieve[n]
        return tmp
    def divisors(self, n:int):
        res = [1]
        prime = self.factorization(n)
        for p in prime:
            newres = []
            for d in res:
                for j in range(prime[p]+1):
                    newres.append(d*p**j)
            res = newres
        res.sort()
        return res
N=int(input())
A=list(map(int,input().split()))

ans = [0]*(10**5+1)
div = tmp(10**5)

for a in A:
    x=0
    for d in div.divisors(a):
        xx = ans[d]
        if xx>x:
            x=xx
    ans[a]=x+1
print(max(ans))
0