about summary refs log tree commit diff
path: root/codechef/qabc.c
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-10-20 11:27:47 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-10-20 11:27:47 +0700
commit4c5ed94087a691ce47882786aea64f7b5bf3c130 (patch)
tree6ebb9374e9c9e1d867659a1de166fbe8f6481b19 /codechef/qabc.c
parent662168dbd56cbeba35bea782d580b0f7cc9a3ac2 (diff)
downloadcp-4c5ed94087a691ce47882786aea64f7b5bf3c130.tar.gz
Bon appétit
Diffstat (limited to 'codechef/qabc.c')
-rw-r--r--codechef/qabc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/codechef/qabc.c b/codechef/qabc.c
new file mode 100644
index 0000000..0dd8b5a
--- /dev/null
+++ b/codechef/qabc.c
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int main()
+{
+	int t, n, i;
+	long *a = malloc(10000 * sizeof(long)), b;
+	scanf("%d\n", &t);
+
+	while (t--) {
+		scanf("%d\n", &n);
+		for (i = 0; i < n; i++)
+			scanf("%ld", a + i);
+		for (i = 0; i < n; i++) {
+			scanf("%ld", &b);
+			a[i] = b - a[i];
+		}
+
+		for (n--; --n; a++) {
+			if (*a < 0) {
+				puts("NIE");
+				break;
+			}
+			if (*a) {
+				a[1] -= *a * 2;
+				a[2] -= *a * 3;
+			}
+		}
+
+		if (n)
+			continue;
+		if (*a || *++a)
+			puts("NIE");
+		else
+			puts("TAK");
+	}
+
+	return 0;
+}