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

请哪位高手帮忙看一下,为什么老是wrong answer???????

Posted by 41147924 at 2007-08-28 09:32:09 on Problem 1247
#include<iostream>
using namespace std;
int a[30];
int main()
{
	int N;
	while(cin>>N)
	{
		if(N==0)
			break;
		int i,j, Esum=0,Ssum=0;
		for(  i=0;i<N;i++)
			cin>>a[i];
        i=0,j=N-i-1;
		for( ;i<j;)
		{
			
			if(Ssum<Esum)
			{
				
				Ssum=Ssum+a[i];
				i=i+1;
			}
			else  if(Ssum>Esum)
			{
				
				Esum=Esum+a[j];
				j--;
			}
			else  if(Ssum==Esum)
			{
				Ssum=Ssum+a[i];
			    Esum=Esum+a[j];
				i++;
				j--;
			}
			
		}
		if((i==j)&&(Esum<Ssum))
		
		{	Esum=Esum+a[j];
		    i--;
		}
		    
		else if((i==j)&&(Esum>=Ssum))
		{	Ssum=Ssum+a[i];
		    j++;
		}
			
				
		if(Ssum==Esum)
			cout<<"Sam stops at position "<<(i+1)<<" and Ella stops at position "<<(j+1)<<"."<<endl;
		else 
			cout<<"No equal partitioning."<<endl;
	}
	return 0;
}


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