結果

問題 No.390 最長の数列
ユーザー chocoruskchocorusk
提出日時 2019-03-31 08:56:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 813 bytes
コンパイル時間 1,109 ms
コンパイル使用メモリ 95,096 KB
実行使用メモリ 7,388 KB
最終ジャッジ日時 2023-08-13 03:48:43
合計ジャッジ時間 2,512 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,348 KB
testcase_01 AC 7 ms
7,284 KB
testcase_02 AC 9 ms
7,280 KB
testcase_03 AC 7 ms
7,224 KB
testcase_04 AC 8 ms
7,344 KB
testcase_05 AC 34 ms
7,344 KB
testcase_06 AC 68 ms
7,388 KB
testcase_07 AC 7 ms
7,336 KB
testcase_08 AC 6 ms
7,280 KB
testcase_09 AC 7 ms
7,304 KB
testcase_10 AC 44 ms
7,276 KB
testcase_11 AC 45 ms
7,224 KB
testcase_12 AC 44 ms
7,304 KB
testcase_13 AC 34 ms
7,232 KB
testcase_14 AC 58 ms
7,300 KB
testcase_15 AC 6 ms
7,280 KB
testcase_16 AC 6 ms
7,260 KB
testcase_17 AC 7 ms
7,300 KB
testcase_18 AC 9 ms
7,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

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