이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |