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<iostream>
#include<algorithm>
using namespace std;
int D[1000][1000];
int M[1000];
int A[1000];
int main(){
int N;
int ans = 0;
cin >> N;
for (int i = 0; i < N; i++){
cin >> A[i];
}
for (int i = 0; i < N; i++){
for (int j = i; j < N; j++){
D[i][j] = D[i][j - 1] + (A[j] * (j - i + 1));
}
}
for (int i = 0; i < N; i++){
M[i] = D[0][i];
for (int j = 0; j <= i; j++){
M[i] = max(M[i], D[j][i] + M[j]);
}
ans = max(M[i], ans);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |