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 LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
const int mod=1e9+7;
int32_t main() {
LCBorz;
int n;cin>>n;
vector<int> v(n+1);
for(int i=1;i<=n;i++){
cin>>v[i];
v[i]+=v[i-1];
}
vector<int> dp(n+5,1),from(n+5);
for(int i=1;i<=n;i++){
from[i]=max(from[i],from[i-1]);
dp[i]=dp[from[i]]+1;
int t=lower_bound(all(v),v[i]*2-v[from[i]])-v.begin();
from[t]=i;
}
cout<<dp[n]<<endl;
return 0;
}
# | 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... |