View Code of Problem 61

#include<stdio.h>

int main() {
	int t, n, s[100], a[100], i, k, max;
	scanf("%d", &t);
	while(t--) {
		max = k = 0;
		scanf("%d", &n);
		for(i=0; i<n; i++){
			scanf("%d", &s[i]);
			if(s[i] > max){
				max = s[i];
				k = i;
			}
		}
		for(i=0; i<n; i++){
			if(i != k) {
				a[i] = s[i] * (n - 1);
				if(a[i] > max)
					max = a[i];
			}
		}
		printf("%d\n", max);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 61