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 a[1111];
long long s[1111];
long long ss[1111];
long long d[1111];
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)scanf("%lld",&a[i]);
for(i=n;i>=0;i--)
{
s[i]=s[i+1]+a[i];
ss[i]=ss[i+1]+s[i+1];
for(j=i+1;j<=n;j++)d[i]=std::max(d[i],d[j]+ss[i]-ss[j]-s[j+1]*(j-i));
}
printf("%lld\n",d[0]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |