結果
問題 | No.2218 Multiple LIS |
ユーザー | nu50218 |
提出日時 | 2023-02-17 21:43:31 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 142 ms / 3,000 ms |
コード長 | 1,307 bytes |
コンパイル時間 | 3,056 ms |
コンパイル使用メモリ | 221,864 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 12:53:24 |
合計ジャッジ時間 | 5,315 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
#ifdef LOCAL #include <local.hpp> #else #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") #include <bits/stdc++.h> #define debug(...) (static_cast<void>(0)) #define postprocess() (static_cast<void>(0)) #endif // #include "atcoder/dsu.hpp" // #include "atcoder/modint.hpp" // using mint = atcoder::modint998244353; // using mint = atcoder::modint1000000007; using namespace std; using ll = long long; using ld = long double; vector<int> divisors(int n) { vector<int> res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i * i != n) { res.push_back(n / i); } } } return res; } void solve([[maybe_unused]] int test) { int N; cin >> N; int dp[100001]; fill(dp, dp + 100001, 0); vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } reverse(A.begin(), A.end()); for (auto&& x : A) { int lis = dp[x]; for (auto&& d : divisors(x)) { dp[d] = max(dp[d], lis + 1); } } cout << *max_element(dp, dp + 100001) << endl; } int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int t = 1; // cin >> t; for (int _t = 1; _t <= t; _t++) solve(_t); postprocess(); }