結果
| 問題 |
No.2218 Multiple LIS
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-17 21:43:31 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 144 ms / 3,000 ms |
| コード長 | 1,307 bytes |
| コンパイル時間 | 11,300 ms |
| コンパイル使用メモリ | 278,852 KB |
| 最終ジャッジ日時 | 2025-02-10 16:37:37 |
|
ジャッジサーバー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();
}