#include<cctype>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;int n,f[250][250],res;
inline LL read()
{
char c;LL d=1,f=0;
while(c=getchar(),!isdigit(c)) if(c=='-') d=-1;f=(f<<3)+(f<<1)+c-48;
while(c=getchar(),isdigit(c)) f=(f<<3)+(f<<1)+c-48;
return d*f;
}
signed main()
{
n=read();
for(register int i=1;i<=n;i++) f[i][i]=read();
for(register int i=n-1;i>=1;i--)
for(register int j=i+1;j<=n;j++){
for(register int k=i;k<j;k++)
if(f[i][k]==f[k+1][j]) f[i][j]=max(f[i][j],f[i][k]+1);res=max(res,f[i][j]);}
printf("%d",res);
}
[USACO16OPEN]248 G
最新推荐文章于 2024-07-23 17:36:37 发布