View Code of Problem 61

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int t,n,a[999];
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
            }
        sort(a,a+n);
        int max=0;
        for(int i=0;i<n;i++){
            if(a[i]*(n-i)>max)
                max=a[i]*(n-i);
        }
        cout<<max<<endl;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 61