# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997826 | daffuwu | Bigger segments (IZhO19_segments) | C++14 | 65 ms | 13136 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 fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[500069], n, a, mx, p[500069];
long long ps[500069];
int main()
{
int i, j;
scanf("%d", &n);
for (i=1; i<=n; i++)
{
scanf("%d", &a);
ps[i] = ps[i-1]+a;
}
for (i=1; i<=n; i++)
{
p[i] = max(p[i-1], p[i]);
dp[i] = dp[p[i]]+1;
j = lower_bound(ps+1, ps+n+1, 2*ps[i]-ps[p[i]])-ps;
p[j] = i;
}
printf("%d\n", dp[n]);
}
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... |