View Code of Problem 61

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int a[n+1]={0};
		for(int i=1;i<=n;i++)
			cin>>a[i];
		sort(a+1,a+n+1);
		int max=0;
		for(int i=1;i<=n;i++)
			if(a[i] * (n-i+1) > max)	max=a[i]*(n-i+1);
		cout<<max<<endl;
	}
} 

Double click to view unformatted code.


Back to problem 61