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 = 3050;
long long a[N], pref[N];
int main() {
long long n;
cin>>n;
for(int i=1; i<=n; i++){
cin>>a[i];
}
pref[1]=a[1];
for(int i=2; i<=n; i++){
pref[i]=pref[i-1]+a[i];
}
long long ans=1, s=0, k=0;
vector <long long> vec;
for(int j=1; j<=n; j++){
s=pref[j];
ans=1;
k=0;
for(int i=j+1; i<=n; i++){
k+=a[i];
if(k >= s){
ans++;
s=k;
k=0;
}
}
vec.push_back(ans);
}
sort(vec.begin(), vec.end());
cout<<vec[(long long)vec.size()-1];
}
# | 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... |