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 <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define fff(i,a,b) for(ll i = a; i < b; i++)
#define MAXN 201
ll dp[MAXN][MAXN], A[MAXN];
ll n;
#define mean(a, b) ((a+b)>>1)
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
fff(i, 0, n){
cin >> A[i];
dp[i][i] = A[i];
}
fff(sz, 2, n+1){
fff(L, 0, n-sz+1){
ll R = L+sz-1;
fff(K, L, R){
dp[L][R] = max(dp[L][R], mean(dp[L][K], dp[K+1][R]));
}
}
}
cout << dp[0][n-1] << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |