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

using namespace std;

int main()
{
    long long n = -1000000000000;
    long long il, dlug, suma = 0, pom = 0;
    vector <long long> ciag;
    vector <long long> akt;
    cin >> il;
    long long roznice [il];
    for (int q = 0; q < il; q++){
        cin >> roznice[q];
    }
    for (int q = 0; q < il; q++){
        akt.push_back(roznice[q]-suma);
        pom++;
        //cout << "suma " << suma << '\n';
        //cout << "dopisuję " << roznice[q]-suma << '\n';
        suma = 0;
        for (int w = pom-1; w >= 0; w--){
            suma += akt[w];
            if (suma > roznice[pom-1-w]){
                cout << "NIE";
                return 0;
            }
        }
    }
    suma = 0;
    for (int w = il-1; w >= 0; w--){
        //cout << akt[w] << ' ';
        suma += akt[w];
        if (suma > roznice[pom-1-w]){
            cout << "NIE";
            return 0;
        }
    }
    cout << "TAK" << '\n' << akt.size() << '\n';
    for (int q = 0; q < akt.size(); q++){
        cout << akt[q] << ' ';
    }
}