結果
問題 | No.390 最長の数列 |
ユーザー | conf |
提出日時 | 2016-07-09 00:07:27 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,441 ms / 5,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 80,036 KB |
実行使用メモリ | 8,448 KB |
最終ジャッジ日時 | 2024-04-10 08:53:21 |
合計ジャッジ時間 | 5,661 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 76 ms
8,192 KB |
testcase_06 | AC | 2,441 ms
8,192 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 5 ms
6,944 KB |
testcase_10 | AC | 283 ms
8,320 KB |
testcase_11 | AC | 298 ms
8,192 KB |
testcase_12 | AC | 272 ms
8,448 KB |
testcase_13 | AC | 396 ms
7,296 KB |
testcase_14 | AC | 470 ms
8,320 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 6 ms
6,944 KB |
testcase_18 | AC | 10 ms
6,944 KB |
ソースコード
#include <iostream> #include <algorithm> #include <map> using namespace std; int main(){ int N; cin>>N; map<int,int> DP; int Xmax=0; for(int i=0;i<N;i++){ int x; cin>>x; DP[x]=1; Xmax=max(x,Xmax); } for(auto ite=DP.begin(); ite!=DP.end();ite++){ int x=ite->first; for(int i=2;x*i<=Xmax;i++){ if(DP.find(x*i)!=DP.end()){ DP[x*i]=max(DP[x*i],DP[x]+1); } } } int ans=1; for(auto ite=DP.begin(); ite!=DP.end();ite++){ ans=max(ans,ite->second); } cout<<ans<<endl; return 0; }