From 7206ecee7579a10dd347d06b397b3790e969f8f3 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Sun, 1 Jan 2017 21:05:53 +0700 Subject: Add others/easy20160714 --- others/easy20160714/03.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 others/easy20160714/03.c (limited to 'others/easy20160714/03.c') diff --git a/others/easy20160714/03.c b/others/easy20160714/03.c new file mode 100644 index 0000000..bec1804 --- /dev/null +++ b/others/easy20160714/03.c @@ -0,0 +1,31 @@ +#include +#include + +int main() +{ + FILE *f = fopen("INP.TXT", "r"); + char n, i; + short *a, b; + long k; + + fscanf(f, "%hhd %ld", &n, &k); + a = malloc(n * sizeof(short)); + + for (i = 0; i < n; i++) + fscanf(f, "%hd", a + i); + + for (i = 0; i < n && k > 0; i++) { + fscanf(f, "%hd", &b); + k -= b - a[i]; + } + + fclose(f); + + f = fopen("OUT.TXT", "w"); + + fprintf(f, "%hhd\n", (n - i) ? i : -1); + + fclose(f); + + return 0; +} -- cgit 1.4.1