View Code of Problem 61

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

Double click to view unformatted code.


Back to problem 61