結果

問題 No.979 Longest Divisor Sequence
ユーザー chocoruskchocorusk
提出日時 2020-01-31 21:49:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 113,892 KB
実行使用メモリ 38,592 KB
最終ジャッジ日時 2023-10-17 09:22:33
合計ジャッジ時間 6,504 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 267 ms
37,424 KB
testcase_01 AC 258 ms
37,424 KB
testcase_02 AC 273 ms
37,424 KB
testcase_03 AC 258 ms
37,424 KB
testcase_04 WA -
testcase_05 AC 258 ms
37,424 KB
testcase_06 AC 255 ms
37,424 KB
testcase_07 AC 259 ms
37,424 KB
testcase_08 WA -
testcase_09 AC 257 ms
37,424 KB
testcase_10 AC 245 ms
37,436 KB
testcase_11 AC 250 ms
37,436 KB
testcase_12 AC 244 ms
37,436 KB
testcase_13 AC 298 ms
38,592 KB
testcase_14 AC 359 ms
38,592 KB
testcase_15 AC 280 ms
37,812 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>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n;
	cin>>n;
	int a[300030];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	vector<int> g[300030];
	for(int d=1; d<=300000; d++){
		for(int i=2; i<=300000/d; i++){
			g[d*i].push_back(d);
		}
	}
	int dp[300030]={};
	for(int i=0; i<n; i++){
		for(auto y:g[a[i]]){
			dp[a[i]]=max(dp[a[i]], dp[y]+1);
		}
	}
	int ans=1;
	for(int i=1; i<=300000; i++) ans=max(ans, dp[i]);
	cout<<ans<<endl;
	return 0;
}
0