제출 #526407

#제출 시각아이디문제언어결과실행 시간메모리
526407MihaiPopaMean (info1cup19_mean)C++14
100 / 100
3 ms588 KiB
#include <bits/stdc++.h> using namespace std; ifstream fin("mean.in"); ofstream fout("mean.out"); const int NMAX = 203, INF = 1e9; int v[NMAX]; long long dp[NMAX][NMAX]; long long mymax(long long a, long long b) { return(a > b ? a : b); } int main() { cin >> v[0]; for(int i = 1; i <= v[0]; ++i) cin >> v[i], dp[i][i] = v[i]; for(int sz = 2; sz <= v[0]; ++sz) { for(int i = 1; i <= v[0] - sz + 1; ++i) { int j = i + sz - 1; dp[i][j] = 0; for(int k = i; k <= j - 1; ++k) dp[i][j] = mymax(dp[i][j], (dp[i][k] + dp[k + 1][j]) >> 1LL); } } cout << dp[1][v[0]] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...