結果
問題 | No.2218 Multiple LIS |
ユーザー | rlangevin |
提出日時 | 2024-04-14 20:03:34 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,241 bytes |
コンパイル時間 | 327 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 78,216 KB |
最終ジャッジ日時 | 2024-04-14 20:03:42 |
合計ジャッジ時間 | 7,584 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
70,712 KB |
testcase_01 | AC | 50 ms
64,256 KB |
testcase_02 | AC | 51 ms
65,020 KB |
testcase_03 | AC | 51 ms
64,084 KB |
testcase_04 | AC | 53 ms
64,364 KB |
testcase_05 | AC | 51 ms
65,124 KB |
testcase_06 | AC | 50 ms
63,868 KB |
testcase_07 | AC | 62 ms
64,712 KB |
testcase_08 | AC | 67 ms
64,664 KB |
testcase_09 | AC | 64 ms
65,816 KB |
testcase_10 | AC | 51 ms
64,432 KB |
testcase_11 | AC | 51 ms
64,952 KB |
testcase_12 | AC | 74 ms
74,768 KB |
testcase_13 | AC | 98 ms
78,216 KB |
testcase_14 | AC | 91 ms
78,104 KB |
testcase_15 | AC | 92 ms
78,124 KB |
testcase_16 | AC | 63 ms
70,116 KB |
testcase_17 | AC | 101 ms
77,952 KB |
testcase_18 | AC | 58 ms
67,792 KB |
testcase_19 | AC | 62 ms
69,804 KB |
testcase_20 | AC | 94 ms
77,856 KB |
testcase_21 | TLE | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
ソースコード
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(10**5+5) pre = defaultdict(lambda : -10) pre[1] = 0 for a in A: dp = defaultdict(lambda : -10) for d in D.div(a): dp[a] = max(dp[a], pre[d] + 1) for k, v in pre.items(): dp[k] = max(dp[k], v) dp, pre = pre, dp ans = 0 for k, v in pre.items(): ans = max(ans, v) print(ans)