View Code of Problem 61

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

Double click to view unformatted code.


Back to problem 61