結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-22 18:37:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 590 bytes |
| コンパイル時間 | 196 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 42,680 KB |
| 最終ジャッジ日時 | 2024-11-27 18:15:51 |
| 合計ジャッジ時間 | 43,370 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 TLE * 6 |
ソースコード
N = int(input())
X = list(map(int, input().split()))
X.sort()
def make_divisors(n):
lower_divisors, upper_divisors = [], []
i = 1
while i * i <= n:
if n % i == 0:
lower_divisors.append(i)
if i != n // i:
upper_divisors.append(n // i)
i += 1
return lower_divisors + upper_divisors[::-1]
dp = [0] * (X[-1] + 1)
for i in range(N):
x = X[i]
x_div = make_divisors(x)
tmp = 0
for xd in x_div:
tmp = max(tmp, dp[xd])
dp[x] = tmp + 1
ans = 0
for val in dp:
ans = max(ans, val)
print(ans)