# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681917 | MilosMilutinovic | Mean (info1cup19_mean) | C++14 | 15 ms | 524 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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
using namespace std;
typedef long long ll;
const int N = 202;
int n;
int a[N];
int dp[N][N];
bool was[N][N];
int solve(int l, int r) {
if (was[l][r]) return dp[l][r];
was[l][r] = true;
if (l == r) return (dp[l][r] = a[l]);
for (int i = l; i < r; i++) {
dp[l][r] = max(dp[l][r], (solve(l, i) + solve(i + 1, r)) / 2);
}
return dp[l][r];
}
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
printf("%d\n", solve(0, n - 1));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |