summaryrefslogtreecommitdiffstats
path: root/inf/lige/1/3.c
diff options
context:
space:
mode:
Diffstat (limited to 'inf/lige/1/3.c')
-rw-r--r--inf/lige/1/3.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/inf/lige/1/3.c b/inf/lige/1/3.c
new file mode 100644
index 0000000..ff62f33
--- /dev/null
+++ b/inf/lige/1/3.c
@@ -0,0 +1,52 @@
+#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");
+ }
+}