結果

問題 No.2218 Multiple LIS
ユーザー lloyzlloyz
提出日時 2023-02-27 21:41:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 682 ms / 3,000 ms
コード長 439 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 91,904 KB
最終ジャッジ日時 2024-09-15 03:31:52
合計ジャッジ時間 9,870 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

def divisors(n):
    L, R = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            L.append(i)
            if n // i != i:
                R.append(n // i)
        i += 1
    return L + R[::-1]

DP = [0 for _ in range(max(A) + 1)]
for i in range(n):
    a = A[i]
    res = 0
    for d in divisors(a):
        res = max(res, DP[d])
    DP[a] = res + 1
print(max(DP))
0