View Code of Problem 61

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>m;
		int a[m];
		for(int j=0;j<m;j++){
			cin>>a[j];
		}
		sort(a,a+m);
		int max=0;
		for(int t=0;t<m;t++){
			if(max<a[t]*(m-t)){
				max=a[t]*(m-t);
			}
		} 
		cout<<max<<endl;
	}
}

Double click to view unformatted code.


Back to problem 61