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 a[1000010],chk[1000010];
long long ans,s,cnt;
int main(){
int i,n;
scanf("%d",&n);
for(i=1;i<=n;++i)scanf("%d",a+i);
for(;i;){
for(;i&&a[i]<=0;--i);
for(s=0;i&&a[i]+s>0;s+=a[i--])chk[i]=1;
}
for(i=1;i<=n;++i){
for(cnt=1;i<=n&&chk[i];)ans+=a[i++]*(cnt++);
}
printf("%lld",ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |