Submission #344971

#TimeUsernameProblemLanguageResultExecution timeMemory
344971jenkinsserBigger segments (IZhO19_segments)C++17
0 / 100
1 ms364 KiB
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define st first #define nd second #define pii pair<int,int> #define N 100005 #define INF 1e9+5 #define sp " " #define nl "\n" #define fastio() ios_base::sync_with_stdio(0);cin.tie(0); #define all(x) (x).begin(),(x).end() #define ll long long using namespace std; int n,a[N],pre[N],dp[N],mx[N],idx; int32_t main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n; for(int i=1;i<=n;i++){ cin >> a[i]; pre[i]=pre[i-1]+a[i]; } for(int i=1;i<=n;i++){ mx[i]=max(mx[i],mx[i-1]); dp[i]=max(dp[i-1],dp[mx[i]]+1); idx=lower_bound(pre,pre+n+1,pre[i]-pre[mx[i]])-pre; mx[idx]=max(mx[idx],i); } cout << dp[n]; }
#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...