結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2023-04-28 10:03:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,559 ms / 5,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 82,628 KB |
実行使用メモリ | 111,392 KB |
最終ジャッジ日時 | 2024-11-17 11:07:59 |
合計ジャッジ時間 | 9,507 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
from collections import defaultdict n=int(input()) x = list(map(int,input().split())) d = defaultdict(int) x.sort() def cal(a): for i in range(1,int(a**0.5)+1): if a%i==0: if i == a: continue if d[i] != 0: d[a] = max(d[i]+1,d[a]) t=a//i if t == a or d[t] == 0: continue d[a] = max(d[t] + 1,d[a]) for i in range(n): now = x[i] if d[1] > 0: d[now] = 2 else: d[now] = 1 cal(now) print(max(d.values()))