結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
le_panda_noir
|
| 提出日時 | 2020-06-13 18:34:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,779 ms / 5,000 ms |
| コード長 | 724 bytes |
| コンパイル時間 | 1,102 ms |
| コンパイル使用メモリ | 89,564 KB |
| 最終ジャッジ日時 | 2025-01-11 03:53:43 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
using vi = vector<int>;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
int main() {
int N;
ins(N);
vi x(N);
rep(i, N) {
cin >> x[i];
}
all(sort, x);
map<int, int> dp;
int ans = 0;
rep(i, N) {
for (int j = 1; j * j <= x[i]; ++j) {
if (x[i] % j == 0)
dp[x[i]] = max(dp[x[i]], max(dp[j]+1, dp[x[i]/j]+1));
}
ans = max(ans, dp[x[i]]);
}
cout << ans << endl;
return 0;
}
le_panda_noir