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
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a[300];
	int base[300];
	int mods[300]; // tu trzymamy ile z liczb musi byc powiekszone o 1
	long long* result = new long long[100000];
	int n;
	
	const long long small = -9999999999999; // -(10^13) +1

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		// i+1 to index normalny
		cin >> a[i];
		mods[i] = a[i] % (i+1); // dla ujemnych liczb będzie ujemne
		base[i] = a[i] / (i+1);
	}

	result[0] = a[0];
	result[1] = small;

	int j = 2; // index result
	for (int i = 1; i < n; i++)
	{
		if ( (base[i] > base[i-1]) || ((mods[i] > mods[i-1])&&(base[i] == base[i-1])) )
		{
			cout << "NIE\n";
			return 0;
		}

		int mods_backup = mods[i];
		for (int k = i; k >= 0; k--)
		{
			int mod = mods_backup != 0 ? (mods_backup > 0 ? 1 : -1) : 0;
			result[j] = base[i] + mod;
			j++;
			if (mods_backup > 0) mods_backup--;
			else if (mods_backup < 0) mods_backup++;
		}

		result[j] = small;
		j++;
	}
	
	cout << "TAK\n";
	cout << j << "\n";
	for (int i = 0; i < j; i++) cout << result[i] << " ";
	cout << "\n";

	return 0;
}