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

大神给看看为什么提交就WA

Posted by huxipeng at 2013-09-16 22:05:02 on Problem 1484
#include<iostream>
#include<string>
using namespace std;
int main()
{   
	int a,b,c,machine[100000],swith[100000],j,i,s;
	int sum;
	int count=0;
	int max;
	while(cin>>a>>b>>c)
	{   
		max=0;
		count++;
		sum=0;
		memset(swith,0,sizeof(swith));
		if(a==0&&b==0&&c==0)
			break;
		for( i=1;i<=a;i++)
		{
			cin>>machine[i];
		}
		for(int j=1;j<=b;j++)
		{
			cin>>s;
			if(swith[s]==0)
			{
				swith[s]=1;
				sum+=machine[s];
				if(sum>c)
					break;
				if(max<sum)
					max=sum;
			}
			else 
			{
				swith[s]=0;
			    sum-=machine[s];
			}
		}
		if(sum>c)
		{
		cout<<"Sequence "<<count<<endl;
		cout<<"Fuse was blown."<<endl<<endl;

		}
		else 
		{
			cout<<"Sequence "<<count<<endl;
			cout<<"Fuse was not blown."<<endl;
		    cout<<"Maximal power consumption was "<<max<<" amperes."<<endl<<endl;
		}

	}
	system("pause");
	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