# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
376282 | Halogen | Bigger segments (IZhO19_segments) | C++14 | 1 ms | 364 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;
#define int long long
int N, presum[500005];
int check(int x) {
int ans = 1, curseg = presum[x];
while (x < N) {
int nx = lower_bound(presum + 1, presum + N + 1, curseg + presum[x]) - presum;
if (presum[nx] - presum[x] - curseg < 0) return 0;
curseg = presum[nx] - presum[x];
ans++;
x = nx;
// printf("%lld\n", x);
}
return ans;
}
main() {
scanf("%lld", &N);
for (int i = 1; i <= N; i++) scanf("%lld", &presum[i]);
for (int i = 2; i <= N; i++) presum[i] += presum[i - 1];
int ans = 1;
for (int x = 1; x <= N; x++) {
ans = max(ans, check(x));
}
printf("%lld\n", ans);
}
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... |