View Code of Problem 61

#include<stdio.h>
#include<stdlib.h>
int main(){
	int cmp(const void *a,const void *b);
	int t;
	scanf("%d",&t);
	while(t-->0){
		int n,max=0;
		scanf("%d",&n);
		int a[n];
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		qsort(a,n,sizeof(int),cmp);
		for(int i=0;i<n;i++){
			if(max<a[i]*(n-i)){
				max=a[i]*(n-i);
			}
		}
		printf("%d\n",max);
	}
	return 0;
}
int cmp(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}

Double click to view unformatted code.


Back to problem 61