結果
| 問題 | No.2218 Multiple LIS |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-16 01:54:26 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 3,000 ms |
| コード長 | 643 bytes |
| 記録 | |
| コンパイル時間 | 1,428 ms |
| コンパイル使用メモリ | 211,324 KB |
| 実行使用メモリ | 7,808 KB |
| 最終ジャッジ日時 | 2026-03-16 01:54:30 |
| 合計ジャッジ時間 | 3,307 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int MAXA = 1000000;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<int> A(N);
for (int &x : A) cin >> x;
vector<int> best(MAXA + 1, 0);
int ans = 0;
for (int x : A) {
int cur = 1;
for (int d = 1; d * d <= x; d++) {
if (x % d == 0) {
cur = max(cur, best[d] + 1);
if (d * d != x)
cur = max(cur, best[x / d] + 1);
}
}
best[x] = max(best[x], cur);
ans = max(ans, cur);
}
cout << ans;
}