View Code of Problem 61

#include <stdio.h>

#define N 1000

int main()
{
	int t, n, a[N], i, j;
	scanf("%d", &t);
	for(i = 0; i < t; i++){
		scanf("%d", &n);
		for(j = 0; j < n; j++){
			scanf("%d", &a[j]);
		}
		int max = a[0] * n;
		int maxi = n;
		for(j = 1; j <= maxi; j++){
			int imax = a[maxi - j] * j;
			if(max < imax){
				max = imax;
			}
		}
		printf("%d\n", max);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 61