Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

看了很久,很长时间,想不明白哪里出错了??哪位大哥帮忙调试一下。。。谢谢

Posted by SilenceIowyh at 2005-09-06 16:20:25 on Problem 2593
#include<stdio.h>
void main()
{
	int m[100001],i,n,sum,b,x[100001],y[100001];
	while(1)
	{
		scanf("%d",&n);
		if(n==0)  break;
		for(i=1;i<=n;i++)
			scanf("%d",&m[i]);
		sum=0;
		b=0;
		for(i=1;i<n;i++)
		{
			if(b>0)
				b+=m[i];
			else b=m[i];
			if(b>sum)
				sum=b;
			x[i]=sum;
		}
		sum=0;
		b=0;
		for(i=n;i>1;i--)
		{
			if(b>0)
				b+=m[i];
			else b=m[i];
			if(b>sum)
				sum=b;
			y[i]=sum;
		}
		sum=x[1]+y[2];
		for(i=2;i<n;i++)
			if((x[i]+y[i+1])>sum)
				sum=x[i]+y[i+1];
		printf("%d\n",sum);
	}
}
















Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator