結果

問題 No.979 Longest Divisor Sequence
ユーザー lilictakalilictaka
提出日時 2022-05-23 21:34:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 154,868 KB
最終ジャッジ日時 2023-10-20 17:44:07
合計ジャッジ時間 2,922 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,500 KB
testcase_01 AC 38 ms
55,500 KB
testcase_02 AC 41 ms
55,500 KB
testcase_03 AC 40 ms
55,500 KB
testcase_04 AC 40 ms
55,500 KB
testcase_05 AC 40 ms
55,500 KB
testcase_06 AC 38 ms
55,500 KB
testcase_07 AC 38 ms
55,500 KB
testcase_08 AC 40 ms
55,500 KB
testcase_09 AC 41 ms
55,500 KB
testcase_10 AC 62 ms
76,244 KB
testcase_11 AC 85 ms
88,312 KB
testcase_12 AC 84 ms
88,256 KB
testcase_13 AC 118 ms
121,608 KB
testcase_14 WA -
testcase_15 AC 324 ms
105,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
memo = [[] for _ in range(MAX+1)]
for i,a in enumerate(A):
    memo[a].append(i)
Aset = set()
dp = [1] * N
for i in range(N-1):
    ai = A[i]
    if ai in Aset:
        continue
    Aset.add(ai)
    for m in range(2,(MAX//ai) + 1):
        if memo[ai * m] == []:
            continue
        index = bisect_left(memo[ai * m],i)
        if index == len(memo[ai * m]):
            continue
        nxi = memo[ai * m][index]
        dp[nxi] = max(dp[i] + 1,dp[nxi])
print(max(dp))
0