#include <bits/stdc++.h>
using namespace std;
const int N=202;
int a[N],dp[N][N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
for(int i=0;i<n;++i)
cin>>a[i];
for(int i=0;i<n;++i)
dp[i][i]=a[i];
for(int len=2;len<=n;++len){
for(int l=0;l+len<=n;++l){
int r=l+len-1;
for(int m=l;m<r;++m)
dp[l][r]=max(dp[l][r],(dp[l][m]+dp[m+1][r])/2);
}
}
cout<<dp[0][n-1];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |