#include <stdio.h> #include <algorithm> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int a[n]; for(int i=0;i<n;++i) scanf("%d",&a[i]); sort(a,a+n); int max=a[0]; for(int i=0;i<n;++i) { int nmax=a[i]*(n-i); if(nmax>max) max=nmax; } printf("%d\n",max); } } |
Double click to view unformatted code.