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>
double arr[1000001];
double sum[1000001];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lf", &arr[i]);
sum[i] = sum[i - 1] + arr[i];
}
int tail = n;
double ans = 0;
for (int i = n; i >= 1; i--) {
if (sum[tail] - sum[i - 1] > 0) {
ans += sum[tail] - sum[i - 1];
}
else {
tail = i - 1;
}
}
printf("%.0lf", ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |