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 nmax = 200;
int dp[nmax + 1][nmax + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ )
cin >> dp[i][i];
for ( int i = 2; i <= n; i++ ) /// lungimea
for ( int j = 1; j <= n - i + 1; j++ ) {
int maxy = 0;
for ( int k = j; k < i + j - 1; k++ )
maxy = max ( maxy, ( dp[j][k] + dp[k + 1][i + j - 1] ) / 2 );
dp[j][i + j - 1] = maxy;
}
cout << dp[1][n];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |