結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 38 ms
7,488 KB
testcase_06 AC 65 ms
7,408 KB
testcase_07 WA -
testcase_08 AC 6 ms
7,420 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
            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