結果
問題 |
No.2218 Multiple LIS
|
ユーザー |
![]() |
提出日時 | 2023-02-27 14:35:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 679 ms / 3,000 ms |
コード長 | 640 bytes |
コンパイル時間 | 593 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 91,264 KB |
最終ジャッジ日時 | 2024-09-14 22:07:00 |
合計ジャッジ時間 | 9,709 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
def divisor(n): sq = n ** 0.5 border = int(sq) table = [] bigs = [] for small in range(1, border + 1): if n % small == 0: table.append(small) big = n // small bigs.append(big) if border == sq: # nが平方数 bigs.pop() table += reversed(bigs) return table n = int(input()) a = list(map(int, input().split())) dp = [0] * (10 ** 5 + 1) dp[1] = 1 for i in range(n): tmp = divisor(a[i]) cnt = -1 v = -1 for j in tmp: if dp[j] > v: cnt = j v = dp[j] dp[a[i]] = max(dp[a[i]], dp[cnt] + 1) print(max(dp)-1)