結果
| 問題 |
No.2218 Multiple LIS
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2023-02-20 20:12:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 694 bytes |
| コンパイル時間 | 620 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 129,432 KB |
| 最終ジャッジ日時 | 2024-07-21 10:59:53 |
| 合計ジャッジ時間 | 12,551 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 TLE * 1 -- * 10 |
ソースコード
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 = [[] 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].append(a)
print(max(E))
ntuda