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];
		int maxi = 0;
		for(j = 0; j < n; j++){
			if(max < a[j]){
				max = a[j];
				maxi = j;
			}
			for(j = 0; j < maxi; j++){
				if(max < a[maxi - j] * (j + 1)){
					max = a[maxi - j] * (j + 1);
				}
			}
		}
		printf("%d\n", max);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 61