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>
long long S[1010000], SS, Res;
int w[1010000];
int n;
int main(){
int i, j;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&w[i]);
S[i]=S[i-1]+w[i];
}
for(i=n;i>=1;i--){
if(w[i] > 0){
SS = 0;
for(j=i-1;j>=0;j--){
if(S[i]<S[j])break;
SS += S[i]-S[j];
}
Res += SS;
i=j+1;
}
}
printf("%lld\n",Res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |