View Code of Problem 61

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

int main()
{
   int t,n,a[1000],i,j;
   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[j] > a[i]){
            int temp = a[j];
            a[j] = a[i];
            a[i] = temp;
           }
        }
    }
    int max = a[0];
    for(i = 1;i <n;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