View Code of Problem 61

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
	int t,n,i,j,temp;
	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+1;j<n;j++){
				if(a[i]<a[j]){
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
			}
		}
		int max=a[0],max1;
		for(i=0;i<n;i++){
			max1=a[i]*(i+1);
			if(max1>max){
				max=max1;
			}
		}
		printf("%d\n",max);
	}
}

Double click to view unformatted code.


Back to problem 61