結果

問題 No.979 Longest Divisor Sequence
ユーザー salmon0852
提出日時 2022-10-27 16:28:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,455 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,960 KB
実行使用メモリ 149,432 KB
最終ジャッジ日時 2024-07-05 01:47:59
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from bisect import bisect_right

n = int(input())
a = [int(i) for i in input().split()]
max_a = max(a)

cnt = [1] * n
d = defaultdict(list)
for i in range(n): d[a[i]].append(i)

for i in range(n):
    x = 2 * a[i]
    while x <= max_a:
        if x in d:
            s = bisect_right(d[x], i)
            for j in d[x][s:]:
                cnt[j] = max(cnt[j], cnt[i] + 1)
        x += a[i]

print(max(cnt))

0