結果

問題 No.390 最長の数列
ユーザー btkbtk
提出日時 2016-07-08 22:56:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 356 ms / 5,000 ms
コード長 584 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 170,540 KB
実行使用メモリ 7,672 KB
最終ジャッジ日時 2024-04-10 08:50:06
合計ジャッジ時間 4,003 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 356 ms
7,672 KB
testcase_06 AC 228 ms
7,624 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 4 ms
7,192 KB
testcase_09 AC 4 ms
7,288 KB
testcase_10 AC 251 ms
7,476 KB
testcase_11 AC 249 ms
7,540 KB
testcase_12 AC 250 ms
7,580 KB
testcase_13 AC 161 ms
7,400 KB
testcase_14 AC 95 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 3 ms
7,200 KB
testcase_17 AC 14 ms
7,116 KB
testcase_18 AC 21 ms
7,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);cout<<fixed;cout<<setprecision(10);}}init;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(it,v) for(auto &it:v)



int main(){
    int N;
    cin>>N;
    vector<int> x(N);
    range(it,x)cin>>it;
    sort(x.begin(),x.end());
    vector<int> dp(x.back()+1,0);
    int res=0;
    range(it,x){
	dp[it]=dp[1]+1;;
	for(int i=2;i*i<=it;i++)
	    if(it%i==0){
		dp[it]=max({dp[it],dp[i]+1,dp[it/i]+1});
	    }
	res=max(res,dp[it]);
    }
    cout<<res<<endl;

    return 0;
}
0