結果
| 問題 |
No.2218 Multiple LIS
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-17 21:27:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 3,000 ms |
| コード長 | 793 bytes |
| コンパイル時間 | 1,966 ms |
| コンパイル使用メモリ | 197,000 KB |
| 最終ジャッジ日時 | 2025-02-10 16:15:52 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
int m = *std::max_element(a.begin(), a.end());
std::vector<std::vector<int>> div(m + 1);
for (int i = 1; i <= m; i++) {
for (int j = i; j <= m; j += i) {
div[j].push_back(i);
}
}
std::vector<int> f(m + 1);
int ans = 0;
for (int i = 0; i < n; i++) {
int v = 0;
for (auto x : div[a[i]]) {
v = std::max(v, f[x] + 1);
}
f[a[i]] = v;
ans = std::max(ans, v);
}
std::cout << ans << "\n";
return 0;
}