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

using namespace std;
vector<long long> result;
int* grow;

bool canBeAdded(long long new_value)
{
    long long sum = new_value;
    for(unsigned long i = result.size(); i > 0; i--)
    {
        if(grow[result.size() - i] < sum)
            return false;
        sum += result[i - 1];
    }
    return true;
}


int main()
{
    ios_base::sync_with_stdio(false);
    int n;

    cin >> n;
    grow = new int[n];

    for(int i = 0; i < n; i++)
        cin >> grow[i];

    result.push_back(grow[0]);

    for(int i = 1; i < n; i++)
    {
        if(canBeAdded(grow[i] - grow[i-1]))
        {
            result.push_back(grow[i] - grow[i-1]);
        }
        else
        {
            cout<<"NIE"<<endl;
            delete [] grow;
            return 0;
        }
    }

    cout<<"TAK"<<endl;
    cout<<result.size()<<endl;
    for(long long i : result)
        cout<<i<<" ";
    cout<<endl;

    delete [] grow;
    return 0;
}