結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2016-07-08 23:46:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 547 bytes |
コンパイル時間 | 650 ms |
コンパイル使用メモリ | 75,288 KB |
実行使用メモリ | 10,988 KB |
最終ジャッジ日時 | 2024-10-13 07:31:50 |
合計ジャッジ時間 | 7,216 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 1 -- * 13 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int N; cin>>N; vector<int> X; for(int i=0;i<N;i++){ int x; cin>>x; X.push_back(x); } sort(X.begin(),X.end()); int dp[N]; fill(dp,dp+N,1); for(int i=0;i<N;i++){ int x=X[i]; for(int j=i+1;j<N;j++){ if(X[j]%x==0&&dp[j]<dp[i]+1)dp[j]=dp[i]+1; } } int ans=1; for(int i=0;i<N;i++){ ans=max(ans,dp[i]); } cout<<ans<<endl; return 0; }