結果

問題 No.2218 Multiple LIS
ユーザー rlangevinrlangevin
提出日時 2024-04-14 20:11:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 292 ms / 3,000 ms
コード長 1,075 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,792 KB
実行使用メモリ 93,504 KB
最終ジャッジ日時 2024-04-14 20:11:44
合計ジャッジ時間 6,886 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
65,136 KB
testcase_01 AC 49 ms
66,452 KB
testcase_02 AC 50 ms
65,396 KB
testcase_03 AC 49 ms
64,836 KB
testcase_04 AC 51 ms
65,524 KB
testcase_05 AC 50 ms
64,780 KB
testcase_06 AC 50 ms
64,836 KB
testcase_07 AC 50 ms
65,052 KB
testcase_08 AC 50 ms
65,572 KB
testcase_09 AC 50 ms
64,600 KB
testcase_10 AC 50 ms
64,680 KB
testcase_11 AC 52 ms
66,524 KB
testcase_12 AC 57 ms
69,476 KB
testcase_13 AC 73 ms
76,104 KB
testcase_14 AC 91 ms
75,368 KB
testcase_15 AC 91 ms
75,592 KB
testcase_16 AC 53 ms
66,292 KB
testcase_17 AC 73 ms
76,636 KB
testcase_18 AC 51 ms
66,384 KB
testcase_19 AC 54 ms
65,832 KB
testcase_20 AC 73 ms
76,740 KB
testcase_21 AC 94 ms
78,628 KB
testcase_22 AC 135 ms
82,292 KB
testcase_23 AC 167 ms
85,940 KB
testcase_24 AC 105 ms
78,816 KB
testcase_25 AC 179 ms
86,788 KB
testcase_26 AC 219 ms
91,544 KB
testcase_27 AC 292 ms
91,596 KB
testcase_28 AC 226 ms
91,596 KB
testcase_29 AC 225 ms
91,840 KB
testcase_30 AC 238 ms
91,720 KB
testcase_31 AC 155 ms
91,244 KB
testcase_32 AC 161 ms
91,504 KB
testcase_33 AC 181 ms
91,768 KB
testcase_34 AC 178 ms
91,392 KB
testcase_35 AC 162 ms
91,364 KB
testcase_36 AC 80 ms
90,368 KB
testcase_37 AC 256 ms
93,504 KB
testcase_38 AC 51 ms
66,048 KB
testcase_39 AC 51 ms
64,964 KB
testcase_40 AC 184 ms
91,832 KB
testcase_41 AC 178 ms
91,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

class Divisor():
    def __init__(self, N):
        self.L = list(range(N + 1))
        for i in range(2, N + 1):
            if i != self.L[i]:
                continue
            for j in range(2 * i, N + 1, i):
                self.L[j] = i

    def factorize(self, n):
        if n <= 1:
            return []
        D = []
        while n != 1:
            cnt = 0
            now = self.L[n]
            while n % now == 0:
                cnt += 1
                n //= now
            D.append((now, cnt))
        return D

    def div(self, n):
        A = self.factorize(n)
        now = [1]
        for k, v in A:
            M = len(now)
            for i in range(M):
                x = now[i]
                for _ in range(v):
                    x *= k
                    now.append(x)
        return now

N = int(input())
A = list(map(int, input().split()))
D = Divisor(101010)
dp = [-10] * 101010
dp[1] = 0
for a in A:
    for d in sorted(D.div(a), reverse=True):
        dp[a] = max(dp[a], dp[d] + 1) 
        
print(max(dp))
0