http://acm.hit.edu.cn/hoj/problem/view?id=1760
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define maxn 10005
using namespace std;
int arry[maxn];
int dp[2];
int n;
void lis(const int *arry){
int i, ans = 0;
memset(dp, 0,sizeof(dp));
for(i = 1;i <= n;i++){
dp[i%2]= arry[i] + max(dp[(i - 1)%2] ,0);
ans = max(ans , dp[i%2]);//滚动数组优化后,时间复杂度为O(1);
}
if(ans)
printf("The maximum winning streak is%d.\n",ans);
else
printf("Losing streak.\n");
}
int main(){
int i;
while(scanf("%d",&n)&&n){
for(i =1;i <=n;i++)
scanf("%d",&arry[i]);
lis(arry);
}
return 0;
}