Submission #959333

#TimeUsernameProblemLanguageResultExecution timeMemory
959333Darren0724Bigger segments (IZhO19_segments)C++17
0 / 100
0 ms348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...