Submission #882152

#TimeUsernameProblemLanguageResultExecution timeMemory
882152preskoBigger segments (IZhO19_segments)C++14
13 / 100
1575 ms600 KiB
#include<iostream> #include<bits/stdc++.h> #define MAXN 500010 using namespace std; long long a[MAXN]; int dfs(int curr, long long sum, int cntr, int n) { long long nsum=0; int ans=cntr; for(int i=curr+1;i<=n;i++) { nsum+=a[i]; if(nsum<sum)ans=max(ans,dfs(i,sum+nsum,cntr,n)); else {ans=max(ans,dfs(i,nsum,cntr+1,n));break;} } return ans; } int main() { int n; ios_base::sync_with_stdio(false); cin.tie(0); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } cout<<dfs(1,a[1],1,n)<<"\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...