Table Strength Practice Coding Problem - CodeChef
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while (t–)
{
int n;
cin >> n;
vector < int > a(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
sort(a.rbegin(), a.rend());
float ans = a[0], m = 2;
for (int i = 1; i < n; i++)
{
if (a[i] * m >= ans)
{
ans = a[i]*m;
m += 1;
}
// else continue;
}
cout << ans << endl;
}
}