結果

問題 No.390 最長の数列
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-26 22:41:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 451 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 194,548 KB
実行使用メモリ 7,632 KB
最終ジャッジ日時 2024-04-25 22:43:16
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
7,348 KB
testcase_01 AC 7 ms
7,632 KB
testcase_02 AC 7 ms
7,396 KB
testcase_03 AC 7 ms
7,520 KB
testcase_04 AC 7 ms
7,476 KB
testcase_05 AC 38 ms
7,472 KB
testcase_06 AC 68 ms
7,480 KB
testcase_07 AC 6 ms
7,392 KB
testcase_08 AC 5 ms
7,516 KB
testcase_09 AC 6 ms
7,476 KB
testcase_10 AC 51 ms
7,376 KB
testcase_11 AC 50 ms
7,464 KB
testcase_12 AC 50 ms
7,556 KB
testcase_13 AC 36 ms
7,464 KB
testcase_14 AC 59 ms
7,620 KB
testcase_15 AC 5 ms
7,552 KB
testcase_16 AC 5 ms
7,412 KB
testcase_17 AC 7 ms
7,576 KB
testcase_18 AC 9 ms
7,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int dp[1000001]{};
    int n;
    cin>>n;
    for (int i=0;i<n;i++) {
        int a;
        cin>>a;
        dp[a]=1;
    }
    for (int i=1;i<=1000000;i++) if (dp[i])
        for (int j=i+i;j<=1000000;j+=i) if (dp[j])
            dp[j]=max(dp[j],dp[i]+1);
    int mx=0;
    for (int i=0;i<=1000000;i++)
        mx=max(mx,dp[i]);
    cout<<mx<<endl;
    return 0;
}
0