summaryrefslogblamecommitdiffstats
path: root/inf/lige/1/3.c
blob: ff62f33aaa8a0babaf164c3a3bc45944d14e078b (plain) (tree)



















































                                                                                                                  
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (void) {
	char buf[128];
	fgets(buf, 128, stdin);
	int p = atoi(buf);
	int * c = calloc(10000, sizeof *c);
	while (p--) {
		fgets(buf, 128, stdin);
		int n = atoi(buf);
		int i = n;
		int sum = 0;
		while (i--) {
			fgets(buf, 128, stdin);
			c[i] = atoi(buf);
			sum += c[i];
			if (!c[i])
				while (1);
		}
		long double avg = (long double) sum/n;
#ifndef EVAL
		fprintf(stderr, "primer %d ima %d števil, katerih avg je %Lf\n", p, n, avg);
#endif
		for (int i = 0; i < n-1; i++) {
			if (c[i] == -1)
				continue;
			if (c[i] == avg)
				continue;
			for (int j = i+1; j < n; j++) {
				if (c[j] == avg)
					continue;
				if (c[j] == -1)
					continue;
#ifndef EVAL
				fprintf(stderr, "avg %d in %d je %Lf\n", c[i], c[j], (long double) (c[i]+c[j])/2);
#endif
				if ((long double) (c[i]+c[j])/2 == avg) {
					c[i] = -1;
					c[j] = -1;
					break;
				}
				if (j == n-1)
					goto bail;
			}
		}
		printf("DA\n");
		continue;
bail:
		printf("NE\n");
	}
}