結果

問題 No.2218 Multiple LIS
ユーザー ntuda
提出日時 2023-02-20 17:00:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 634 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 154,568 KB
最終ジャッジ日時 2024-07-21 09:00:44
合計ジャッジ時間 11,961 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 TLE * 1 -- * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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]


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))
0