View Code of Problem 61

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int n,m,max,x;
  scanf("%d",&m);
  while(m--){
    scanf("%d",&n);
    int r[n];
    for(int j=0;j<n;j++){
      scanf("%d",&r[j]);
    }
    sort(r,r+n);
    max = 0;
    for(int j=n-1;j>=0;j--){
      x = r[j]*(n-j);
      if(x>max)
        max = x;
    }
    printf("%d\n",max);
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 61