結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2017-05-03 12:26:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 5,000 ms |
コード長 | 411 bytes |
コンパイル時間 | 1,514 ms |
コンパイル使用メモリ | 170,908 KB |
実行使用メモリ | 7,808 KB |
最終ジャッジ日時 | 2024-10-02 12:10:10 |
合計ジャッジ時間 | 2,471 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> #define REP(i,n,N) for(int i=(n);i<(int)N;i++) #define p(s) cout<<(s)<<endl using namespace std; int dp[1000010]; int main(){ int N; cin>>N; int x[100010]; REP(i,0,N) cin>>x[i]; sort(x,x+N); REP(i,0,N) dp[x[i]]=1; REP(i,0,N){ for(int j=x[i]*2;j<=x[N-1];j+=x[i]){ if(dp[j]==0) continue; dp[j] = max(dp[j],dp[x[i]]+1); } } p(*max_element(dp,dp+x[N-1]+1)); return 0; }