結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-14 23:20:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 582 ms / 5,000 ms |
| コード長 | 375 bytes |
| コンパイル時間 | 256 ms |
| コンパイル使用メモリ | 82,032 KB |
| 実行使用メモリ | 244,992 KB |
| 最終ジャッジ日時 | 2024-09-19 14:39:56 |
| 合計ジャッジ時間 | 3,819 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#配るDP
from collections import defaultdict
N = int(input())
x = list(map(int, input().split()))
x.sort()
flag = defaultdict(int)
for xi in x:
flag[xi] = 1
A = max(x)
dp = [1] * (A+1)
for xi in x:
mult = 2
while mult * xi <= A:
if flag[mult*xi]:
dp[mult*xi] = max(dp[mult*xi], dp[xi]+1)
mult += 1
print(max(dp))