Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rubabredwan committed Apr 23, 2017
1 parent b59dc79 commit 74cc3f0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Random/usaco open 2016/262144.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n) for(int i=0;i<n;i++)
#define repn(i, n) for(int i=1;i<=n;i++)
#define set(i, n) memset(i, n, sizeof(i))

#define pb push_back

using namespace std;

const int N = 300000;
const int K = 70;

int dp[N][K], n, a[N];

int main(){
freopen("262144.in", "r", stdin);
freopen("262144.out", "w", stdout);
scanf("%d", &n);
repn(i, n) scanf("%d", &a[i]);
int ret = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=65;j++){
if(a[i] == j) dp[i][j] = i;
else if(!dp[i][j-1] || !dp[ dp[i][j-1]-1 ][ j-1 ]) continue;
else dp[i][j] = dp[ dp[i][j-1]-1 ][ j-1 ];
ret = max(ret, j);
}
}
printf("%d\n", ret);
return 0;
}

0 comments on commit 74cc3f0

Please sign in to comment.