【算法】DP
【题解】开long long……
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=50010; int a[maxn],n; int main() { scanf("%d",&n); long long sum=0,ans=0,x; for(int i=1;i<=n;i++) { scanf("%lld",&x); sum+=x; ans=max(ans,sum); if(sum<0)sum=0; } printf("%lld",ans); return 0; }