結果
| 問題 | No.979 Longest Divisor Sequence |
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2020-01-31 21:55:39 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 187 ms / 2,000 ms |
| + 701µs | |
| コード長 | 666 bytes |
| 記録 | |
| コンパイル時間 | 1,467 ms |
| コンパイル使用メモリ | 214,844 KB |
| 実行使用メモリ | 38,272 KB |
| 最終ジャッジ日時 | 2026-10-19 15:01:15 |
| 合計ジャッジ時間 | 5,642 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
int n;
cin>>n;
vector<int> as(n);
for(int i=0;i<n;i++) cin>>as[i];
const int MAX = 3e5 + 100;
vector< vector<int> > G(MAX);
for(int i=1;i<MAX;i++)
for(int j=i+i;j<MAX;j+=i)
G[j].emplace_back(i);
vector<int> dp(MAX,-MAX);
int ans=0;
for(int a:as){
chmax(dp[a],1);
for(int d:G[a])
chmax(dp[a],dp[d]+1);
chmax(ans,dp[a]);
}
cout<<ans<<endl;
return 0;
}
beet