結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
|
| 提出日時 | 2022-04-16 14:29:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 651 bytes |
| コンパイル時間 | 301 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 190,416 KB |
| 最終ジャッジ日時 | 2024-12-25 18:10:19 |
| 合計ジャッジ時間 | 5,472 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 1 |
ソースコード
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))