結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
convexineq
|
| 提出日時 | 2020-01-31 23:15:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 917 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 147,788 KB |
| 最終ジャッジ日時 | 2024-09-17 10:32:26 |
| 合計ジャッジ時間 | 4,704 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 1 |
ソースコード
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read
n,*a = [int(i) for i in read().split()]
MAX = 1+3*10**5
#MAX = 20
ans = [1]*n
d = {}
for i,ai in enumerate(a):
if ai in d:
d[ai].append(i)
else:
d[ai] = [i]
sa = sorted([(ai,i) for i,ai in enumerate(a)],key = lambda x: x[0])
from bisect import bisect_left
from itertools import groupby
for k,g in groupby(sa,key = lambda x: x[0]):
c = sorted([[i,ans[i]] for a,i in g],key = lambda x: x[0])
l = len(c)
for i in range(1,l):
c[i][1] = max(c[i][1],c[i-1][1])
#print(k,c)
for p in range(2*k,MAX,k):
if p in d:
for j in d[p]:
idx = bisect_left(c,[j,-1])
#print(k,p,idx,j,ans)
if idx >= 1:
ans[j] = max(ans[j],c[idx-1][1]+1)
#print(ans)
print(max(ans))
convexineq