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