#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
vector<pair<int,int>> dp[n + 1];
dp[0].push_back({0, 0});
for(int i = 1; i <= n; i++) {
int sum = 0;
for(int j = i; j >= 1; j--) {
sum += a[j];
for(auto it : dp[j - 1]) {
if(sum >= it.second) {
dp[i].push_back({it.first + 1, sum});
}
}
}
}
int ans = 0;
for(auto it : dp[n]) {
ans = max(ans, it.first);
}
cout << ans;
}
# | 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... |