結果

問題 No.979 Longest Divisor Sequence
ユーザー lilictakalilictaka
提出日時 2022-05-23 21:53:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 607 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 155,004 KB
最終ジャッジ日時 2023-10-20 17:44:47
合計ジャッジ時間 3,135 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,500 KB
testcase_01 AC 40 ms
55,500 KB
testcase_02 AC 40 ms
55,500 KB
testcase_03 AC 40 ms
55,500 KB
testcase_04 AC 40 ms
55,500 KB
testcase_05 AC 39 ms
55,500 KB
testcase_06 AC 39 ms
55,500 KB
testcase_07 AC 39 ms
55,500 KB
testcase_08 AC 39 ms
55,500 KB
testcase_09 AC 38 ms
55,500 KB
testcase_10 AC 62 ms
76,244 KB
testcase_11 AC 87 ms
88,308 KB
testcase_12 AC 80 ms
88,272 KB
testcase_13 AC 120 ms
121,608 KB
testcase_14 WA -
testcase_15 AC 296 ms
105,488 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):
    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