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
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n{};
    cin >> n;

    int a[301]{};
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<int> rank{};
    rank.push_back(a[0]);
    
    for (int i = 1; i < n; i++) {
        rank.push_back(a[i]-a[i-1]);
        int sum{};
        for (int j = i; j > 0; j--) {
            sum += rank[j];
            if (sum > a[i-j]) {
                cout << "NIE\n";
                return 0;
            }
        }
    }
    cout << "TAK\n" << rank.size() << "\n";

    for (int num : rank) cout << num << " ";
    cout << "\n";
}