結果

問題 No.390 最長の数列
ユーザー irumo8202irumo8202
提出日時 2022-01-22 18:37:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,788 ms / 5,000 ms
コード長 590 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 99,572 KB
最終ジャッジ日時 2023-08-18 13:04:16
合計ジャッジ時間 10,800 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,348 KB
testcase_01 AC 71 ms
71,572 KB
testcase_02 AC 71 ms
71,304 KB
testcase_03 AC 72 ms
71,576 KB
testcase_04 AC 75 ms
71,196 KB
testcase_05 AC 1,788 ms
99,340 KB
testcase_06 AC 1,175 ms
98,644 KB
testcase_07 AC 72 ms
71,640 KB
testcase_08 AC 78 ms
83,540 KB
testcase_09 AC 78 ms
83,448 KB
testcase_10 AC 1,279 ms
99,496 KB
testcase_11 AC 1,278 ms
99,200 KB
testcase_12 AC 1,296 ms
99,572 KB
testcase_13 AC 950 ms
95,384 KB
testcase_14 AC 626 ms
91,988 KB
testcase_15 AC 76 ms
75,888 KB
testcase_16 AC 83 ms
83,984 KB
testcase_17 AC 143 ms
84,560 KB
testcase_18 AC 180 ms
85,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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