From 4c5ed94087a691ce47882786aea64f7b5bf3c130 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sat, 20 Oct 2018 11:27:47 +0700 Subject: Bon appétit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codechef/qabc.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 codechef/qabc.py (limited to 'codechef/qabc.py') diff --git a/codechef/qabc.py b/codechef/qabc.py new file mode 100755 index 0000000..f3f9c60 --- /dev/null +++ b/codechef/qabc.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python2 +from operator import not_, sub +from sys import stdin + +for _ in xrange(int(stdin.readline())): + n = int(stdin.readline()) + a = map(int, stdin.readline().split()) + b = map(int, stdin.readline().split()) + c = map(sub, b, a) + for i in xrange(n - 2): + if c[i] < 0: + print 'NIE' + break + c[i + 1] -= c[i] * 2 + c[i + 2] -= c[i] * 3 + else: + if n < 3: + print 'NIE' if any(c) else 'TAK' + else: + print 'TAK' if c[-2] == c[-1] == 0 else 'NIE' -- cgit 1.4.1