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 <bits/stdc++.h>
using namespace std;
const int N = 5050 , inf = 1e9 + 199;
int32_t main()
{
/// freopen("subsequence.in","r",stdin);
/// freopen("subsequence.out","w",stdout);
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
int say = 1,preind = 0 , presum = a[0] , cursum = 0;
for(int i=1;i<n;i++){
cursum += a[i];
if(cursum < presum){
continue;
}
while(preind + 1 < i){
if(presum + a[preind + 1] > cursum - a[preind + 1]){
break;
}
presum += a[preind + 1];
cursum -= a[preind + 1];
preind ++;
}
say++;
presum = cursum;
preind = i;
cursum = 0;
}
if(cursum >= presum){
say++;
}
cout << say << endl;
}
/*
*/
# | 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... |