View Code of Problem 61

#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int a[n];
        for(int i=0;i<n;++i)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int max=-1;
        for(int i=0;i<n;++i)
        {
            int nmax=a[i]*(n-i);
            if(nmax>max)
                max=nmax;
        }
        printf("%d\n",max);
    }
}

Double click to view unformatted code.


Back to problem 61