View Code of Problem 61

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,i;
	int a[10005];
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
		scanf("%d",&a[i]);
		sort(a,a+n);
		int max=0;
		for(i=0;i<n;i++)
		{
			if(a[i]*(n-i)>max)
			max=a[i]*(n-i);
		}
		printf("%d\n",max);
			}
			return 0;
		}
	

Double click to view unformatted code.


Back to problem 61