#include<stdio.h> #include<stdlib.h> int cmp(const void *a,const void *b) { return *(int *)a-*(int *)b; } int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int a[n],i; for(i=0;i<n;i++) scanf("%d",&a[i]); qsort(a,n,sizeof(int),cmp); int max=a[0]*n; for(i=1;i<n;i++) { if(max<a[i]*(n-i)) max=a[i]*(n-i); } printf("%d\n",max); } } |
Double click to view unformatted code.