View Code of Problem 61

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		int a[n];
		int i,j;
		for(i=0;i<n;i++)
		{
			scanf("%d",a[i]);
		}
		for(i=0;i<n;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if(a[i]<a[j])
				{
					int tmp;
					tmp=a[j];
					a[j]=a[i];
					a[i]=tmp;
				}
			}
		}
		int max=a[0];
		for(i=0;i<n;i++)
		{
			if((i+1)*a[i]>max)
				max=(i+1)*a[i];
		}
		printf("%d\n",max);
	}
}

Double click to view unformatted code.


Back to problem 61