View Code of Problem 61

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t, n, max, tmp;
    cin >> t;
    while(t--){
        cin >> n;
        int input[n];
        for(int i = 0; i < n; i++)
            cin >> input[i];
        sort(input,input+n);
        max = input[0];
        for(int i = 0; i < n; i++){
            tmp = (n-i)*input[i];
            if(tmp > max)
                max = tmp;
        }
        cout << max << endl;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 61