View Code of Problem 61

#include <stdio.h>
#include <math.h>
#include <string.h>
#include<algorithm>
using namespace std;
int main()
{
	int t, n, i, s, max;
	int a[999];
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}
		sort(a, a + n);
		max = a[0];
		for (i = 0; i < n; i++) {
				s = a[i] * (n-i);
				if (s > max) {
					max = s;
				}			
		}
		printf("%d\n", max);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 61