Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
偶没办法了,朋友们,求救!!!!!/////////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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator