View Code of Problem 61

#include<bits/stdc++.h>
using namespace std;                          
#define max 101     
/*1 2 4 
1 10 15
 5 7 1 6 9 10 

若将n根绳子扭在一起来吊起一个重量为w的物体,那每根绳子所承受的重量为w/n
*/
bool cmp (int a,int b);          
int main(){      
	 int n,m,a[100] = { },max1,max2;
	 cin>>n;
	 for(int u = 0; u<n;u++){
	 	cin>>m;
	 	for(int i = 0;i<m;i++)cin>>a[i];
	 	sort(a,a+m,cmp);
	 	max2 = a[1];
	 	cout<<max2*2<<endl;
	 }          
	return 0;
}
bool cmp(int a,int b){
	return a>b;
}

Double click to view unformatted code.


Back to problem 61