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 <iostream>
using namespace std;
const int MAXN = 205;
int dp[MAXN][MAXN];
int v[MAXN];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; ++i ) {
cin >> v[i];
}
for ( int i = 1; i <= n; ++i ) {
dp[i][i+1] = (v[i] + v[i+1]) / 2;
dp[i][i] = v[i];
}
for ( int l = 3; l <= n; ++l ) {
for ( int i = 1; i <= n - l + 1; ++i ) {
int j = i + l - 1;
for ( int x = i; x < j; ++x ) {
dp[i][j] = max( dp[i][j], (dp[i][x] + dp[x + 1][j]) / 2 );
}
}
}
cout << dp[1][n];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |