結果

問題 No.390 最長の数列
ユーザー recososorecososo
提出日時 2020-02-26 14:31:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 1,856 ms
コンパイル使用メモリ 165,200 KB
実行使用メモリ 7,688 KB
最終ジャッジ日時 2024-04-21 16:23:29
合計ジャッジ時間 3,045 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
7,440 KB
testcase_01 AC 6 ms
7,632 KB
testcase_02 AC 6 ms
7,184 KB
testcase_03 AC 6 ms
7,424 KB
testcase_04 AC 6 ms
7,520 KB
testcase_05 AC 34 ms
7,552 KB
testcase_06 AC 63 ms
7,688 KB
testcase_07 AC 6 ms
7,352 KB
testcase_08 AC 5 ms
7,424 KB
testcase_09 AC 6 ms
7,324 KB
testcase_10 AC 40 ms
7,564 KB
testcase_11 AC 43 ms
7,560 KB
testcase_12 AC 42 ms
7,680 KB
testcase_13 AC 33 ms
7,564 KB
testcase_14 AC 54 ms
7,564 KB
testcase_15 AC 5 ms
7,336 KB
testcase_16 AC 5 ms
7,424 KB
testcase_17 AC 6 ms
7,552 KB
testcase_18 AC 7 ms
7,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<int> x(n);
    int dp[1000001];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
        cin >> x[i];
        dp[x[i]]=1;
    }
    for(int i=1;i<1000001;i++){
        if(dp[i]){
            for(int j=2;j*i<=1000000;j++){
                if(dp[i*j]){
                    dp[i*j]=max(dp[i*j],dp[i]+1);
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<1000001;i++){
        ans=max(ans,dp[i]);
    }
    cout << ans << endl;
}
0