This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,i,j,k,dp[205][205];
int main()
{
//freopen("in","r",stdin);
//freopen("out","w",stdout);
cin.sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(i=1;i<=n;++i)
{
int x;
cin>>x;
dp[i][i]=x;
}
for(i=n-1;i>=1;--i)
{
for(j=i+1;j<=n;++j)
{
for(k=i;k<j;++k)
{
dp[i][j]=max(dp[i][j],(dp[i][k]+dp[k+1][j])/2);
}
}
}
cout<<dp[1][n]<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |