很简单的线性动态规划
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
int m;
int dp[10001];
int h[10001];
int Aimee[10001];
int ans=0;
int main(){
scanf("%d",&m);
for(int i=1; i<=m;++i){
scanf("%d",&h[i]);
Aimee[i]=Aimee[i-1]+h[i];
}
for(int i=1;i<=m;++i){
for(int j=0;j<i;++j){
if([i]-Aimee[j]>=0){
if(dp[j]==0&&j!=0)
continue;
dp[i]=max(dp[j]+1,dp[i]);
}
}
}
if(dp[m]==0)
cout<<"Impossible";
else
cout<<dp[m];
return 0;
}