#include <iostream> using namespace std; int main(){ int n; while(cin>>n){ if(n==0) break; int a[n+10],dp[n+10],ans; for(int i=0;i<n;i++) cin>>a[i]; ans=a[0]; for(int i=0;i<n;i++){ int t=0; for(int j=i;j<n;j++){ t+=a[j]; ans=max(ans,t); } } cout<<ans<<endl; } return 0; } |
Double click to view unformatted code.