状态转移方程max=(a[i],sum[i-1]+a[i])#includestdio.h int main() { int r=1; int n,m; int z=0; int p,q; int i,j,k,t,x,y; int max; scanf("%d",n); while(n--) { p=-999999; max=-1; t=0; k=1; j=1; y=0; scanf("%d",m); while(m--) { scanf("%d",i
状态转移方程max=(a[i],sum[i-1]+a[i])
#include<stdio.h>
int main()
{
int r=1;
int n,m;
int z=0;
int p,q;
int i,j,k,t,x,y;
int max;
scanf("%d",&n);
while(n--)
{
p=-999999;
max=-1;
t=0;
k=1;
j=1;
y=0;
scanf("%d",&m);
while(m--)
{
scanf("%d",&i);
y++;
if(p<i)
{
p=i;
q=y;
}
t+=i;
if(t>max)
{
max=t;
k=j;
x=y;
}
if(t<0)
{
j=y+1;
t=0;
}
}
if(r==1)
r=0;
else
printf("\n");printf("Case %d:\n",++z);
if(p>=0)
printf("%d %d %d\n",max,k,x);
else
printf("%d %d %d\n",p,q,q);
}
return 0;
}
【转自:美国高防服务器 http://www.558idc.com/usa.html转载请说明出处】