結果

問題 No.979 Longest Divisor Sequence
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-16 14:33:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 742 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 141,812 KB
最終ジャッジ日時 2023-08-26 18:15:07
合計ジャッジ時間 3,939 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
83,016 KB
testcase_01 AC 84 ms
82,852 KB
testcase_02 AC 90 ms
83,076 KB
testcase_03 AC 85 ms
83,084 KB
testcase_04 AC 85 ms
82,996 KB
testcase_05 AC 84 ms
83,044 KB
testcase_06 AC 85 ms
82,888 KB
testcase_07 AC 83 ms
82,924 KB
testcase_08 AC 85 ms
83,016 KB
testcase_09 AC 85 ms
82,864 KB
testcase_10 AC 94 ms
83,360 KB
testcase_11 AC 97 ms
83,808 KB
testcase_12 AC 96 ms
83,548 KB
testcase_13 AC 140 ms
125,044 KB
testcase_14 AC 742 ms
141,812 KB
testcase_15 AC 280 ms
102,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

n = int(input())
A = list(map(int,input().split()))
M = 3*10**5+5
count = [0]*M
for a in A:
    count[a] += 1

lis = [[] for i in range(M)]
for i in range(M)[::-1]:
    if count[i] == 0:
        continue
    for j in range(i*2,M,i):
        if count[j]:
            lis[j].append(i)

ans = [0]*M

for a in A:
    cand = 0
    for j in lis[a]:
        cand = max(cand,ans[j])
    ans[a] = cand+1
print(max(ans))
0