Submission #521349

#TimeUsernameProblemLanguageResultExecution timeMemory
521349raidMean (info1cup19_mean)C++17
100 / 100
3 ms460 KiB
#include <iostream> using namespace std; const int MAXN = 205; int dp[MAXN][MAXN]; int v[MAXN]; int main() { int n; cin >> n; for ( int i = 1; i <= n; ++i ) { cin >> v[i]; } for ( int i = 1; i <= n; ++i ) { dp[i][i+1] = (v[i] + v[i+1]) / 2; dp[i][i] = v[i]; } for ( int l = 3; l <= n; ++l ) { for ( int i = 1; i <= n - l + 1; ++i ) { int j = i + l - 1; for ( int x = i; x < j; ++x ) { dp[i][j] = max( dp[i][j], (dp[i][x] + dp[x + 1][j]) / 2 ); } } } cout << dp[1][n]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...