题解1:
\(Code\)
#include<bits/stdc++.h>
using namespace std;
int a[255]={0};
int f[255][255]={0};
int main()
{
int n,ans=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
f[i][i]=a[i];
ans=max(ans,a[i]);
}
for(int d=2;d<=n;d++)
for(int i=1;i+d-1<=n;i++)
{
int l=i,r=i+d-1;
for(int j=l;j<r;j++) if(f[l][j]==f[j+1][r]&&f[l][j]) f[l][r]=f[l][j]+1;
ans=max(ans,f[l][r]);
}
cout<<ans<<endl;
return 0;
}
标签:P3146,int,USACO16OPEN,ans,248,255
From: https://www.cnblogs.com/pure4knowledge/p/17990930