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;
const int MAXN = 200 + 11;
int a[MAXN];
int dp[MAXN][MAXN];
int main(){
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 d = 1; d < n; d++){
for(int i = 0; i < n - d; i++){
int l = i, r = i + d;
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] << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |