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 namespace std;
#define fi first
#define se second
const int MOD = 1e9+7;
int N;
long long arr[201];
long long DP[201][201];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> arr[i];
DP[i][1] = arr[i];
}
for (int i = 2; i <= N; i++) {
for (int j = 2; j <= i; j++) {
DP[i][j] = max(DP[i][j], (DP[i][j-1]+arr[i-j+1])/2);
}
for (int j = 2; j <= i; j++) {
DP[i][i] = max(DP[i][i], (DP[i][j-1]+DP[i-j+1][i-j+1])/2);
}
}
cout << DP[N][N] << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |