# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
376950 | joelau | Bigger segments (IZhO19_segments) | C++14 | 1 ms | 492 KiB |
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 <bits/stdc++.h>
using namespace std;
int N,ans[500000];
long long A[500001], sz[500000];
int main() {
scanf("%d", &N);
A[0] = 0;
for (int i = 1; i <= N; ++i) {
scanf("%lld", &A[i]);
A[i] += A[i-1];
}
ans[0] = 1, sz[0] = A[1];
for (int i = 1, j = 0; i < N; ++i) {
while (j < i && sz[j] <= A[i+1] - A[j+1]) j++;
if (j == 0) ans[i] = 1, sz[i] = A[i+1];
else ans[i] = ans[j-1]+1, sz[i] = A[i+1] - A[j];
}
printf("%d", ans[N-1]);
return 0;
}
Compilation message (stderr)
# | 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... |