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>
using namespace std;
long long n,v[500010],suma[500010],ans;
int main()
{
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>v[i];
}
ans=1;
suma[1]=v[1];
int poz=2;
for(int i=2;i<=n;++i)
{
suma[ans+1]+=v[i];
if(suma[ans]<=suma[ans+1])
{
++ans;
while(suma[ans]-v[poz]>=v[poz]+suma[ans-1])
{
suma[ans]-=v[poz];
suma[ans-1]+=v[poz];
++poz;
}
poz=i+1;
}
}
cout<<ans;
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... |