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