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

using namespace std;

int seq[400];
int sum[400];
int maxi[400];

int main() {
	int n;
	cin >> n;
	bool bad = false;
	for (int i = 1; i <= n; i++) {
		cin >> maxi[i];
		seq[i] = maxi[1];
		for (int j = 1; j <= i; j++) {
			seq[i] = min(maxi[i] - (sum[i - 1] - sum[j]), seq[i]);
		}
		if (seq[i] < maxi[i] - sum[i - 1]) {
			bad = true;
			break;
		}
		sum[i] = sum[i - 1] + seq[i];
	}
	if (!bad) {
		cout << "TAK\n";
		cout << n << "\n";
		for (int i = 1; i <= n; i++) {
			cout << seq[i] << " ";
		}
	}
	else {
		cout << "NIE\n";
	}
	return 0;
}