View Code of Problem 61

#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool compare(int a,int b)
{
	return a<b;
}

int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int max=0,j,b=0;
		scanf("%d",&m);
		vector<int> a(m);
		for(int i=0;i<m;i++)
		{
			scanf("%d",&a[i]);
		}
		sort(a.begin(),a.end(),compare);
		for(j=0;j<n;j++)
		{
			b++;
			if(a[j]*b>max)     
			{
				max=a[j]*b;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 61