1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
using namespace std;

long sum(long *a) {
	long sum = 0;
	for(int i = 0; i < 300; i++) {
		sum += a[i];
	}
	return sum;
}

void printArray(long *a, int n) {
	for(int i = 0; i < n; i++) {
		cout<< a[i] << " ";
	}
}

int main() {
	long result[300] = { 0 };
	bool solved = false;

	int n;
	cin >> n;

	int max;
	cin >> max;

	result[0] = max;

	for (int i = 0; i < n - 1; i++) {
		int a;
		cin >> a;

		if(a - sum(result) > max) {
			cout << "NIE";
			solved = true;
			break;
		} else {
			result[i + 1] = a - sum(result);
		}
	}

	if(!solved ) {
		cout << "TAK" << endl;
		cout << n << endl;
		printArray(result, n);
	}
	return 0;
}