about summary refs log tree commit diff
path: root/others/easy20160714/26.c
diff options
context:
space:
mode:
Diffstat (limited to 'others/easy20160714/26.c')
-rw-r--r--others/easy20160714/26.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/others/easy20160714/26.c b/others/easy20160714/26.c
new file mode 100644
index 0000000..f7c2d0e
--- /dev/null
+++ b/others/easy20160714/26.c
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+	FILE *f = fopen("INP.TXT", "r");
+	int n, k, *a, i;
+	long long s = 0;
+
+	fscanf(f, "%d %d", &n, &k);
+	a = malloc(n * sizeof(int));
+
+	for (i = 0; i < n; i++) {
+		fscanf(f, "%d", a + i);
+		s += a[i];
+	}
+
+	fclose(f);
+
+	k = s / k;
+	s = 0;
+
+	for (i = 0; i < n; i++) {
+		s += a[i];
+
+		if (s == k)
+			s = 0;
+	}
+
+	f = fopen("OUT.TXT", "w");
+	fputs(s ? "NO\n" : "YES\n", f);
+	fclose(f);
+
+	return 0;
+}