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
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int n;
	
	string s;
	std::cin >> n;
	int a[300];
	vector<int> v;
	for (int i = 0; i < n; i++)
	{
		std::cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		int m = a[0];
		int s = 0;
		for (int j = 1; j <= i; j++)
		{
			s += v[i - j];
			int mj = a[j] - s;
			m = std::min(m, mj);
		}
		if (s + m < a[i])
		{
			cout << "NIE";
			return 0;
		}
		v.push_back(a[i] - s);
	}
	cout << "TAK\n";
	cout << v.size() + 1 << endl;
	for (int i = 0; i < v.size(); i++)
	{
		cout << v[i] << " ";
	}
	cout << INT_MIN;
	return 0;
}