結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
chocopuu
|
| 提出日時 | 2020-01-31 22:36:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,834 ms / 2,000 ms |
| コード長 | 1,389 bytes |
| コンパイル時間 | 3,064 ms |
| コンパイル使用メモリ | 196,264 KB |
| 実行使用メモリ | 13,800 KB |
| 最終ジャッジ日時 | 2024-09-17 09:15:50 |
| 合計ジャッジ時間 | 7,214 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
#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;
}
chocopuu