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;
ifstream fin("mean.in");
ofstream fout("mean.out");
const int NMAX = 203, INF = 1e9;
int v[NMAX];
long long dp[NMAX][NMAX];
long long mymax(long long a, long long b)
{
return(a > b ? a : b);
}
int main()
{
fin >> v[0];
for(int i = 1; i <= v[0]; ++i)
fin >> v[i], dp[i][i] = v[i];
for(int sz = 2; sz <= v[0]; ++sz) {
for(int i = 1; i <= v[0] - sz + 1; ++i) {
int j = i + sz - 1;
dp[i][j] = 0;
for(int k = i; k <= j - 1; ++k)
dp[i][j] = mymax(dp[i][j], (dp[i][k] + dp[k + 1][j]) >> 1LL);
}
}
fout << dp[1][v[0]] << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |