diff options
Diffstat (limited to 'others/easy20160714/24.c')
-rw-r--r-- | others/easy20160714/24.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/others/easy20160714/24.c b/others/easy20160714/24.c new file mode 100644 index 0000000..2422b35 --- /dev/null +++ b/others/easy20160714/24.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +int main() +{ + FILE *f = fopen("INP.TXT", "r"); + int n, k, a, i, b = 0, r = 1; + + fscanf(f, "%d %d", &n, &k); + + for (i = 0; i < n; i++) { + fscanf(f, "%d", &a); + if (a + b > k) { + b = 0; + r++; + } + b += a; + } + + fclose(f); + + f = fopen("OUT.TXT", "w"); + fprintf(f, "%d\n", r); + fclose(f); + + return 0; +} |