#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #define N 100 using namespace std; int main() { int t; scanf("%d",&t); while(t--) { int n,max; scanf("%d",&n); int str[n]; for(int i=0;i<n;i++) { scanf("%d",&str[i]); } sort(str,str+n); max=str[0]*n; for(int i=0;i<n;i++) { if(max<str[i]*(n-i)) { max=str[i]*(n-i); } } printf("%d\n",max); } return 0; } |
Double click to view unformatted code.