結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
AEn
|
| 提出日時 | 2022-05-16 21:20:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,754 ms / 5,000 ms |
| コード長 | 566 bytes |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 119,680 KB |
| 最終ジャッジ日時 | 2024-09-14 14:24:18 |
| 合計ジャッジ時間 | 11,055 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
from collections import defaultdict
N = int(input())
S = list(map(int, input().split()))
S.sort()
s = set(S)
d = defaultdict(int)
if N == 1:
print(1)
exit()
for ss in S:
d[ss] = 1
def yaku(X):
res = 1
for i in range(1, X+1):
if i*i > X:
break
if X%i == 0:
if i in s:
res = max(res, d[i]+1)
if i*i != X and X//i in s and X//i != X:
res = max(res, d[X//i]+1)
d[X] = res
return res
ans = 0
for i in range(1, N):
ans = max(ans, yaku(S[i]))
print(ans)
AEn