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 <iostream>
using namespace std;
long long n, a[500010], l, r, lst, cnt, sum;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
l = r = 1;
sum = a[1];
while (r <= n) {
if (sum < lst) sum += a[++r];
else {
while ((l < r) && (sum-a[l] >= lst+a[l])) {
lst += a[l];
sum -= a[l++];
}
lst = sum;
cnt++;
l = ++r;
sum = a[r];
}
}
cout << cnt << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |