33,007
社区成员
发帖
与我相关
我的任务
分享
//sample input
//4
//2 -1 3 1
//sample output
//5
// 答案有误
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int a[100],n;
while(scanf("%d",&n)==1 && n){
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
int m=0,ans=0;
for(int i=0;i<n;i++){
m=max(m+a[i],0);
ans=max(ans,m);
}
printf("%d\n",ans);
}
system("pause");
return 0;
}