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 ll = long long;
const int MAX_N = 200;
int a[1 + MAX_N], dp[1 + MAX_N + 1][1 + MAX_N];
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int n;
std::cin >> n;
for (int i = 1; i <= n; i++) {
std::cin >> a[i];
}
for (int i = 1; i <= n; i++) {
dp[i][i] = a[i];
}
for (int h = 2; h <= n; h++) {
for (int i = 1; i + h - 1 <= n; i++) {
int j = i + h - 1;
for (int k = i; k <= j; k++) {
dp[i][j] = std::max(dp[i][j], (dp[i][k] + dp[k + 1][j]) / 2);
}
}
}
std::cout << dp[1][n];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |