結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2016-07-08 22:56:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 364 ms / 5,000 ms |
| コード長 | 584 bytes |
| コンパイル時間 | 1,682 ms |
| コンパイル使用メモリ | 171,912 KB |
| 実行使用メモリ | 7,556 KB |
| 最終ジャッジ日時 | 2024-10-02 10:33:10 |
| 合計ジャッジ時間 | 4,159 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);cout<<fixed;cout<<setprecision(10);}}init;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(it,v) for(auto &it:v)
int main(){
int N;
cin>>N;
vector<int> x(N);
range(it,x)cin>>it;
sort(x.begin(),x.end());
vector<int> dp(x.back()+1,0);
int res=0;
range(it,x){
dp[it]=dp[1]+1;;
for(int i=2;i*i<=it;i++)
if(it%i==0){
dp[it]=max({dp[it],dp[i]+1,dp[it/i]+1});
}
res=max(res,dp[it]);
}
cout<<res<<endl;
return 0;
}
btk