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<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 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... |