結果

問題 No.979 Longest Divisor Sequence
ユーザー tko919tko919
提出日時 2020-01-31 21:53:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,029 bytes
コンパイル時間 2,596 ms
コンパイル使用メモリ 169,552 KB
実行使用メモリ 27,956 KB
最終ジャッジ日時 2023-10-17 09:31:36
合計ジャッジ時間 3,633 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_10 WA -
testcase_11 AC 3 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 61 ms
27,956 KB
testcase_14 WA -
testcase_15 AC 26 ms
12,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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