# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494817 | nickmet2004 | Bigger segments (IZhO19_segments) | C++11 | 89 ms | 20828 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 int long long
using namespace std;
const int N = 1e6 + 5;
int n , a[N] , dp[N] , b[N] , p[N];
main (){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i = 1; i<= n;++i)cin >> a[i];
for(int i =1;i <= n; ++i) p[i] = p[i - 1] + a[i];
for(int i = 1; i<= n; ++i){
b[i] = max(b[i] , b[i - 1]);
dp[i]= dp[b[i]] + 1;
int x= lower_bound(p + 1 , p + 1 + n , 2*p[i] - p[b[i]]) - p;
b[x] = max(b[x] , i);
}cout << 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... |