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

using namespace std;

#define f first
#define s second

const int MAXN = 313;

int t[MAXN];
int ans[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, E;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
        ans[i] = t[i] - t[i - 1];
    }
    for (int i = 1; i <= n; i++) {
        E = 0;
        for (int j = 1; j < i; j++)
            E += ans[j];
        for (int j = i; j <= n; j++) {
            E += ans[j] - ans[j - i];
            if (E > t[i]) {
                cout << "NIE";
                return 0;
            }
        }
    }
    cout << "TAK\n" << n << "\n";
    for (int i = 1; i <= n; i++)
        cout << ans[i] << ' ';
    return 0;
}