http://acm.hit.edu.cn/hoj/problem/view?id=1760
dp 最大字段和
d[i]=tmp+max(0,d[i-1]);
/*This Code is Submitted by billforum for Problem 4000110 at 2012-02-02 17:36:05*/
#include <iostream>
#include <algorithm>
#include <memory.h>
using namespace std;
int d[10001]={0};
int max(int x,int y)
{
return (x>y?x:y);
}
int main(int args,char** argv)
{
int n,tmp,ans;
while(cin>>n&&n)
{
ans=0;
for(int i=0;i<n;i++)
{
cin>>tmp;
if(i>0) d[i]=tmp+max(0,d[i-1]);
else d[i]=tmp;
}
for(int i=0;i<n;i++)
{
if(d[i]>ans) ans=d[i];
}
if(ans>0) cout<<"The maximum winning streak is "<<ans<<"."<<endl;
else cout<<"Losing streak."<<endl;
}
return 0;