View Code of Problem 61

#include<stdio.h>
int main(){
	int i,j,t,n,h,max;
	int a[1000];

	scanf("%d",&t);	
	while(t--)	
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(i=0;i<n;i++)
			for(j=i;j<n;j++)
				if(a[i]<a[j])
				{
					h=a[i];
					a[i]=a[j];
					a[j]=h;
				}
				max=a[0];
		for(i=0;i<n;i++)
				if( a[i]*(i+1)>max)
					max=a[i]*(i+1);
		
		if(t>0)
			printf("%d\n",max);
		else
			printf("%d",max);		
	}
  return 0;	
}

Double click to view unformatted code.


Back to problem 61