简单题
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#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 ;
}
#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 ;
}