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
57
58
59
#include <bits/stdc++.h>
#define gc getchar
#define gcu getchar_unlocked
#define fi first
#define se second
#define pb push_back
#define mod ((ll)1e9 + 7)
typedef long long ll;
using namespace std;
//===============================================================================================

int n;
ll a[10009], b[10009];

//===============================================================================================
int main()
{
    scanf("%d", &n);
    for (int i = 0, temp; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if (!i)
        {
            b[i] = a[i];
            continue;
        }
        b[i] = a[i] - a[i - 1];
        if (b[i] > b[0])
        {
            printf("NIE\n");
            return 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        ll sum = 0, maxsum = LLONG_MIN;
        for (int j = 0; j < i; j++)
            sum += b[j];
        for (int j = i; j < n; j++)
        {
            sum += b[j];
            maxsum = max(maxsum, sum);
            sum -= b[j - i];
        }
        if (maxsum != a[i])
        {
            printf("NIE\n");
            return 0;
        }
    }
    printf("TAK\n%d\n", n);
    for (int i = 0; i < n; i++)
        printf("%lld ", b[i]);
}
//===============================================================================================
// 4
// 3 4 5 -1
// 10
// 3 1 4 1 5 9 2 6 5 3