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 bluenight at 2006-07-07 22:00:26 on Problem 2291
/////////2291///////////////////
#include<iostream>
using namespace std;
int main()
{
	int testcase,num_of_ropes,i,j,temp,max;
	cin>>testcase;
	if(testcase>0&&testcase<11)
	{
	while(testcase-->0)
	{
		cin>>num_of_ropes;
		max=temp=0;
		int*weight=new int[num_of_ropes];
		for(i=0;i<num_of_ropes;i++)
		    cin>>weight[i];
         for(i=0;i<num_of_ropes-1;i++)
			 for(j=1;j<num_of_ropes;j++)
				 if(weight[i]>weight[j])
				 {
					 temp=weight[j];
					 weight[j]=weight[i];
					 weight[i]=temp;
				 } 
				 max=weight[0]*num_of_ropes;
				 for(i=1;i<num_of_ropes;i++)
					 if(weight[i]*(num_of_ropes-i)>max)
                      max=weight[i]*(num_of_ropes-i);
            cout<<max<<endl;   
		delete[]weight;
	
	}
	}
	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