summaryrefslogtreecommitdiffstats
path: root/inf/zotks/2.c
diff options
context:
space:
mode:
Diffstat (limited to 'inf/zotks/2.c')
-rw-r--r--inf/zotks/2.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/inf/zotks/2.c b/inf/zotks/2.c
new file mode 100644
index 0000000..6f71e5b
--- /dev/null
+++ b/inf/zotks/2.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <signal.h>
+#define N unsigned long long int
+N s (N n) {
+ return (n*(n+1))/2;
+}
+int main (void) {
+ char buf[256];
+ fgets(buf, 256, stdin);
+ while (1) {
+ fgets(buf, 256, stdin);
+ if (ferror(stdin) || feof(stdin))
+ break;
+ char * c;
+ N n = strtoull(buf, &c, 10); // imamo n števil
+ N m = strtoull(++c, &c, 10); // vsota vseh teh n števil je m
+ N k = strtoull(++c, NULL, 10); // teh n števil razdelimo v k skupin
+ if (k > n) { // ni možno imeti več skupin kot elementov
+ fprintf(stdout, "NE\n");
+ continue;
+ }
+ N smallest_max_in_group = n / k;
+ // fprintf(stderr, "smallest_max_in_group: %llu, s(smig+1)\n", smallest_max_in_group);
+ if ((n % k)*s(smallest_max_in_group+1) + (k-(n % k))*s(smallest_max_in_group) > m)
+ fprintf(stdout, "NE\n");
+ else
+ fprintf(stdout, "DA\n");
+ }
+ return 0;
+}