結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
55,480 KB
testcase_01 AC 39 ms
55,480 KB
testcase_02 AC 40 ms
55,480 KB
testcase_03 AC 40 ms
55,480 KB
testcase_04 AC 40 ms
55,480 KB
testcase_05 AC 41 ms
55,480 KB
testcase_06 AC 42 ms
55,480 KB
testcase_07 WA -
testcase_08 AC 42 ms
55,480 KB
testcase_09 AC 40 ms
55,480 KB
testcase_10 AC 86 ms
88,224 KB
testcase_11 AC 85 ms
88,260 KB
testcase_12 AC 86 ms
88,328 KB
testcase_13 AC 104 ms
121,556 KB
testcase_14 WA -
testcase_15 AC 271 ms
113,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
newA = []
Aset = set()
for a in A:
    if a in Aset:
        continue
    newA.append(a)
    Aset.add(a)
N = len(newA)
A = newA
memo = [[] for _ in range(MAX+1)]
for i,a in enumerate(A):
    memo[a].append(i)
dp = [1] * N
for i in range(N-1):
    ai = A[i]
    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