結果

問題 No.979 Longest Divisor Sequence
ユーザー chocopuuchocopuu
提出日時 2020-01-31 22:36:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,838 ms / 2,000 ms
コード長 1,389 bytes
コンパイル時間 3,331 ms
コンパイル使用メモリ 195,424 KB
実行使用メモリ 13,796 KB
最終ジャッジ日時 2023-10-17 10:54:37
合計ジャッジ時間 6,950 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 12 ms
4,348 KB
testcase_11 AC 12 ms
4,348 KB
testcase_12 AC 12 ms
4,348 KB
testcase_13 AC 49 ms
4,400 KB
testcase_14 AC 1,838 ms
13,796 KB
testcase_15 AC 1,428 ms
13,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e9;

#include"ext/pb_ds/assoc_container.hpp"
#include"ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
template<typename T>
using pbds = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

/*
insert(logN)
erase(logN)
find_by_order(logN)//k番目の要素のイテレータを返す
order_of_key(logN)//k以上で最初の数が何番目かを返す
(K未満の個数が何個あるかが分かるらしい)
gp_hash_table<int,int>m//高速なmap
*/

signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	REP(i,N)cin >> a[i];
	gp_hash_table<int,int>mp;
	REP(i,N){
		int ma = 0;
		for(int j = 1;j * j <= a[i];j++){
			if(a[i] % j)continue;
			if(j<a[i])CHMAX(ma,mp[j]);
			if(a[i]/j<a[i])CHMAX(ma,mp[a[i]/j]);
		}
		if(mp[a[i]]<ma+1)mp[a[i]]=ma+1;
	}
	int ans = 0;
	for(auto e:mp)CHMAX(ans,e.second);
	cout << ans << endl;
}
0