#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e6+5;
int a[N];
pair<int,int> dp[N];
int ps[N];
signed main(){
int n;
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=0;j<i;j++){
if(-dp[j].ss <= ps[i]-ps[j]){
dp[i]=max(dp[i],{dp[j].ff+1,-(ps[i]-ps[j])});
break;
}
}
}
cout<<dp[n].ff;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |