View Code of Problem 61

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

Double click to view unformatted code.


Back to problem 61