結果

問題 No.390 最長の数列
ユーザー dnishdnish
提出日時 2017-05-03 12:26:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 5,000 ms
コード長 411 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 166,244 KB
実行使用メモリ 7,924 KB
最終ジャッジ日時 2024-04-10 10:20:44
合計ジャッジ時間 3,038 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 44 ms
6,940 KB
testcase_06 AC 67 ms
7,744 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 48 ms
7,924 KB
testcase_11 AC 48 ms
7,716 KB
testcase_12 AC 47 ms
7,892 KB
testcase_13 AC 36 ms
7,808 KB
testcase_14 AC 40 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 7 ms
7,512 KB
testcase_18 AC 8 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;

int dp[1000010];
int main(){
	int N;
	cin>>N;
	int x[100010];
	REP(i,0,N) cin>>x[i];
	sort(x,x+N);
	REP(i,0,N) dp[x[i]]=1;
	REP(i,0,N){
		for(int j=x[i]*2;j<=x[N-1];j+=x[i]){
			if(dp[j]==0) continue;
			dp[j] = max(dp[j],dp[x[i]]+1);
		}
	}
	p(*max_element(dp,dp+x[N-1]+1));
	return 0;
}
0