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;
long long n,a[3005],dp[3005][3005],ps[3005],ans;
int main(){
ios::sync_with_stdio(false);
cin >> n;
for (int i=1;i<=n;i++){
cin >> a[i];
ps[i]=ps[i-1]+a[i];
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++){
dp[i][j]=1e18;
}
}
for (int i=1;i<=n;i++){
dp[i][1]=ps[i];
for (int j=2;j<=n;j++){
for (int k=1;k<i;k++){
if (dp[k][j-1] <= ps[i]-ps[k])
dp[i][j]=min(dp[i][j],ps[i]-ps[k]);
}
}
}
for (int i=1;i<=n;i++){
if (dp[n][i] != 1e18)
ans=i;
}
cout << ans << "\n";
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... |