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>
#include <string>
#define ll long long
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=222;
ll n;
ll a[maxn];
ll dp[maxn][maxn];
int main()
{
IOS
cin>>n;
for(ll i=0;i<n;i++)cin>>a[i];
for(ll r=0;r<n;r++){
dp[r][r]=a[r];
for(ll l=r-1;l>=0;l--){
for(ll mid=l;mid<r;mid++){
dp[l][r]=max(dp[l][r],(dp[l][mid]+dp[mid+1][r])/2);
}
}
}
cout<<dp[0][n-1]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |