View Code of Problem 61

#include<stdio.h>
int main(){
	int t;
    scanf("%d",&t);
	int a[1000];
	int count;
	int max;
	while(t--){	
	    int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		  scanf("%d",&a[i]);
		max=0;
		for(int i=0;i<n;i++){
		  count=0;
		  for(int j=0;j<n;j++)
		     if(a[i]<=a[j])
		      count++;

		  if(max<a[i]*count)
		    max=a[i]*count;
		}
		printf("%d\n",max);
	}
} 


Double click to view unformatted code.


Back to problem 61