結果

問題 No.979 Longest Divisor Sequence
コンテスト
ユーザー tko919
提出日時 2020-01-31 21:53:19
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,029 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,164 ms
コンパイル使用メモリ 182,852 KB
実行使用メモリ 28,160 KB
最終ジャッジ日時 2026-04-06 04:37:07
合計ジャッジ時間 1,819 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0