# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
376951 | joelau | Bigger segments (IZhO19_segments) | C++14 | 1590 ms | 2012 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];
}
for (int i = 0; i < N; ++i) {
ans[i] = 1, sz[i] = A[i+1];
for (int j = i-1; j >= 0; --j) if (sz[j] <= A[i+1] - A[j+1]) {
ans[i] = ans[j]+1, sz[i] = A[i+1] - A[j+1];
break;
}
}
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... |