#include<stdio.h> #include <string.h> #include <math.h> int main(){ int n; int t; int i,j; scanf("%d",&n); int a[1000]; while(n--){ scanf("%d",&t); for(i=0;i<t;i++){ scanf("%d",&a[i]); } int temp; int min; for(i=0;i<t;i++){ min=i; for(j=i;j<t;j++){ if(a[min]<a[j]){ temp=a[min]; a[min]=a[j]; a[j]=temp; } } } int max=a[0]; for(i=0;i<t;i++){ if(max<a[i]*(i+1)){ max=a[i]*(i+1); } } printf("%d\n",max); } return 0; } |
Double click to view unformatted code.