結果

問題 No.390 最長の数列
ユーザー persimmon-persimmon
提出日時 2021-06-17 09:12:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,478 ms / 5,000 ms
コード長 318 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 231,668 KB
最終ジャッジ日時 2025-01-02 11:15:13
合計ジャッジ時間 5,361 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
a.sort()
s=set(a)
m=max(a)+1
g=[[] for _ in range(m+1)]
for x in a:
  xx=x+x
  while xx<=m:
    if xx in s:
      g[xx].append(x)
    xx+=x
mat=[0]*m
seen=[1]*(m+1)
for v in a[::-1]:
  for nv in g[v]:
    if seen[nv]<seen[v]+1:
      seen[nv]=seen[v]+1
print(max(seen))
0