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

Re:讨论中的问题都注意了,但还是WA。大侠们帮我看看吧,为什么WA

Posted by 767401875 at 2009-07-22 18:57:57 on Problem 1477
In Reply To:讨论中的问题都注意了,但还是WA。大侠们帮我看看吧,为什么WA Posted by:radiance at 2009-03-11 14:15:38
> #include <iostream>
> #include <vector>
> using namespace std;
> 
> int process(vector<int> &input)
> {
> 	int averageHeight=0, totalHeight=0;
> 
> 	//算平均值
> 	for ( int i=1; i<input.size(); i++ )
> 	{
> 		totalHeight += input[i];
> 	}
> 	averageHeight = totalHeight/input[0];
> 
> 	int counter = 0;
> 
> 	for ( int i=1; i<input.size(); i++ )
> 	{
> 		if ( (input[i]-averageHeight) > 0 )
> 		{
> 			counter += input[i]-averageHeight; 
> 		}
> 	}
> 	
> 	return counter;
> }
> 
> int main()
> {
> 	int a;
> 	vector<int> input;
> 	int caseNo=1;
> 
> 	while ( cin>>a )
> 	{
> 		if ( a!=0 )
> 		{
> 			input.push_back(a);
> 		}
> 		else
> 		{
> 			cout<<"Set #"<<caseNo<<endl<<"The minimum number of moves is "<<process( input )<<"."<<endl<<endl;
> 			caseNo++;
> 			input.clear();
> 		}
> 	}
> 
> 	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