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<cstdio>
#include<algorithm>
long long c[1500];
long long dp[1500];
int main()
{
int N;
scanf("%d",&N);
for(int i=1;i<=N;i++)
scanf("%lld",c+i);
dp[N+1]=0;
for(int i=N;i>=0;i--)
{
dp[i]=dp[i+1];
long long inc=0;
for(int j=i+1;j<=N+1;j++)
{
inc+=(j-i-1)*c[j-1];
dp[i]=std::max(dp[j]+inc,dp[i]);
}
}
printf("%lld",dp[0]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |