# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501126 | NachoLibre | Bigger segments (IZhO19_segments) | C++17 | 69 ms | 13000 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>
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
const int N = 500005;
int n, b[N][2];
ll a[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
a[i] += a[i - 1];
} a[n + 1] = 1e17;
b[1][0] = 1; b[1][1] = 0;
int x = 0, y = 0;
for(int i = 1; i <= n; ++i) {
if(b[i][0] >= x) { x = b[i][0]; y = max(b[i][1], y); }
int l = i + 1, r = n + 1;
while(l < r) {
int m = l + r >> 1;
if(a[m] - a[i] >= a[i] - a[y]) r = m;
else l = m + 1;
}
if(x + 1 >= b[l][0]) { b[l][0] = x + 1; b[l][1] = i; }
// cout << i << " " << x << " " << y << endl;
}
cout << x << endl;
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... |