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<stdio.h>
int n;
long long int a[1001000];
long long int s[1001000];
long long int d[1001000];
long long int dp[1001000];
int main(){
long long int i,j,k;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lld",&a[i]);
s[i+1]=s[i]+a[i];
d[i+1]=d[i]+s[i+1];
}
for(i=0;i<=n;i++){
printf("%lld ",dp[i]);
k=0;
for(j=i+1;j<=n+1;j++){
if(dp[j]<dp[i]+k)dp[j]=dp[i]+k;
k+=a[j-1]*(j-i);
}
}
printf("%lld",dp[n+1]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |