結果
| 問題 |
No.979 Longest Divisor Sequence
|
| コンテスト | |
| ユーザー |
tko919
|
| 提出日時 | 2020-01-31 21:53:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,029 bytes |
| コンパイル時間 | 1,763 ms |
| コンパイル使用メモリ | 169,552 KB |
| 実行使用メモリ | 27,988 KB |
| 最終ジャッジ日時 | 2024-09-17 07:59:44 |
| 合計ジャッジ時間 | 2,595 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 4 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end
int dp[301000][20]={};
int main(){
int n; scanf("%d",&n);
rep(i,0,n+1)rep(j,0,20)dp[i][j]=inf;
dp[0][0]=0;
vector<int> a(n);
rep(i,0,n)scanf("%d",&a[i]);
rep(i,0,n){
rep(j,0,20)chmin(dp[i+1][j],dp[i][j]);
rep(j,0,19){
if(dp[i][j]==0||(a[i]%dp[i][j]==0&&a[i]>dp[i][j])){
chmin(dp[i+1][j+1],a[i]);
}
}
}
rrep(j,19,-1)if(dp[n][j]!=inf){
printf("%d\n",j); return 0;
}
return 0;
}
tko919