結果

問題 No.979 Longest Divisor Sequence
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-16 14:29:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 651 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 197,884 KB
最終ジャッジ日時 2023-08-26 18:12:54
合計ジャッジ時間 6,870 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
98,968 KB
testcase_01 AC 117 ms
98,492 KB
testcase_02 AC 116 ms
98,532 KB
testcase_03 AC 116 ms
98,608 KB
testcase_04 AC 119 ms
98,732 KB
testcase_05 AC 118 ms
98,572 KB
testcase_06 AC 119 ms
98,660 KB
testcase_07 AC 121 ms
98,528 KB
testcase_08 AC 120 ms
98,564 KB
testcase_09 AC 119 ms
98,572 KB
testcase_10 AC 147 ms
94,452 KB
testcase_11 AC 124 ms
94,176 KB
testcase_12 AC 124 ms
94,696 KB
testcase_13 AC 273 ms
155,124 KB
testcase_14 TLE -
testcase_15 AC 710 ms
124,856 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]*n
res = [[] for i in range(M)]
sA = [[a,i] for i,a in enumerate(A)]
sA.sort()

for a,ind in sA:
    cand = 1
    for nex in lis[a]:
        if res[nex]:
            nind = bisect.bisect_left(res[nex],ind)
            if nind:
                cand = max(cand,ans[res[nex][nind-1]]+1)
    ans[ind] = cand
    res[a].append(ind)

print(max(ans))
0