简单题
View Code
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define maxn 1006
int f[maxn];
int main()
{
//freopen("t.txt", "r", stdin);
int t;
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &f[i]);
sort(f, f + n);
int ans = 0;
for (int i = n - 1; i >= 0; i--)
if ((n - i) * f[i] > ans)
ans = (n - i) * f[i];
printf("%d\n", ans);
}
return 0;
}