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<bits/stdc++.h>
using namespace std;
int n,T[1000];
vector <int> V;
int findmax (int n);
int main()
{
    cin >> n;
    for (int i = 1 ; i <= n ;  i++)
    {
        cin >> T[i];
    }
    int dasie = 1;
    V.push_back(T[1]);
    for (int i = 2 ; i <= n ; i++)
    {
        if(T[i] - T[i-1] > T[1])
            dasie = 0;
    }
    if(dasie == 0)
    {
        cout << "NIE";
        return 0;
    }
    for (int i = 2 ; i <= n ; i++)
    {
        V.push_back(T[i] - T[i-1]);
    }
    for (int i = 2 ; i <= n ; i++)
    {
        if(findmax(i) != T[i])
        {
            cout <<"NIE";
            return 0;
        }
    }

    cout << "TAK\n"<<V.size()<<"\n";
    for (int i = 0 ; i < V.size() ; i++)
        cout << V[i]<<" ";

}
int findmax (int n)
{
    int ob = 0;
    for (int i = 0 ; i < n ; i++)
        ob += V[i];
    int maxw = ob;
    for (int i = n, lewy = 0 ;  i < V.size() ; i++,lewy++)
    {
        ob += V[i];
        ob -= V[lewy];
        maxw = max(maxw,ob);
    }
    return maxw;
}