結果

問題 No.390 最長の数列
ユーザー btkbtk
提出日時 2016-07-08 22:56:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 364 ms / 5,000 ms
コード長 584 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 169,472 KB
実行使用メモリ 7,640 KB
最終ジャッジ日時 2023-07-25 16:56:22
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 364 ms
7,364 KB
testcase_06 AC 233 ms
7,444 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
7,076 KB
testcase_09 AC 4 ms
6,900 KB
testcase_10 AC 257 ms
7,404 KB
testcase_11 AC 257 ms
7,640 KB
testcase_12 AC 257 ms
7,236 KB
testcase_13 AC 184 ms
7,168 KB
testcase_14 AC 98 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 4 ms
6,876 KB
testcase_17 AC 16 ms
6,976 KB
testcase_18 AC 23 ms
6,872 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