# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645315 | notme | Mean (info1cup19_mean) | C++14 | 4 ms | 596 KiB |
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>
#define endl '\n'
using namespace std;
const long long MAXN = 205;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n, a[MAXN];
long long dp[MAXN][MAXN];
void solve()
{
cin >> n;
for (long long i = 1; i <= n; ++ i)
cin >> a[i];
for (int i = 1; i <= n; ++ i)
dp[i][1] = a[i];
for (int len = 2; len <= n; ++ len)
{
for (int i = 1; i + len - 1 <= n; ++ i)
{
int j = i + len - 1;
for (int k = 1; k <= len-1; ++ k)
{
long long res1 = dp[i][k];
long long res2 = dp[i+k][len-k];
dp[i][len] = max(dp[i][len], 1LL * (res1 + res2)/2);
}
///cout << i << " " << len << " - > " << dp[i][len] << endl;
}
}
cout << dp[1][n] << endl;
}
int main()
{
speed();
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |