Submission #640171

#TimeUsernameProblemLanguageResultExecution timeMemory
640171tvladm2009Mean (info1cup19_mean)C++14
100 / 100
2 ms468 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...