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;
int main() {
ios_base::sync_with_stdio(0);
int n;
cin>>n;
int a[n];
for(int i = 0; i < n; i += 1)cin>>a[i];
///dp[p] = {ans, min_sum}
pair<int,long long> dp[n];
long long sum = 0;
for(int i = 0; i < n; i += 1){
sum += a[i];
dp[i] = {1, -sum};
}
for(int i = 1; i < n; i += 1){
sum = 0;
for(int j = i - 1; j >= 0; j -= 1){
sum += a[j + 1];
if(-dp[j].second <= sum)dp[i] = max(dp[i], {dp[j].first + 1, -sum});
}
}
int ans = 0;
for(int i = 0; i < n; i += 1){
ans = max(ans, dp[i].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... |