結果

問題 No.390 最長の数列
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-17 09:12:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,167 ms / 5,000 ms
コード長 318 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 228,700 KB
最終ジャッジ日時 2023-08-30 17:40:03
合計ジャッジ時間 8,011 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,416 KB
testcase_01 AC 71 ms
71,444 KB
testcase_02 AC 71 ms
71,432 KB
testcase_03 AC 69 ms
71,396 KB
testcase_04 AC 71 ms
71,448 KB
testcase_05 AC 166 ms
119,132 KB
testcase_06 AC 2,167 ms
228,700 KB
testcase_07 AC 482 ms
70,956 KB
testcase_08 AC 129 ms
119,068 KB
testcase_09 AC 137 ms
119,568 KB
testcase_10 AC 301 ms
136,356 KB
testcase_11 AC 317 ms
136,252 KB
testcase_12 AC 308 ms
136,724 KB
testcase_13 AC 206 ms
119,012 KB
testcase_14 AC 352 ms
111,016 KB
testcase_15 AC 75 ms
75,776 KB
testcase_16 AC 128 ms
118,824 KB
testcase_17 AC 137 ms
116,684 KB
testcase_18 AC 139 ms
115,688 KB
権限があれば一括ダウンロードができます

ソースコード

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