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
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int N;
int I;
int Sum[10000];
int Sequence[10000];

int getMaxSumForRange(int n) {
    int left = 1;
    int right = n;
    int sum = 0;
    for (int i = 1; i <= right; i++)
        sum += Sequence[i];
    int max = sum;
    while (right <= I) {
        if (sum > max)
            max = sum;
        sum -= Sequence[left];
        left++;
        right++;
        sum += Sequence[right];
    }
    return max;
}

int main()
{
    Sum[0] = 0;
    scanf("%d", &N);
    for (I = 1; I <= N; I++) {
        scanf("%d", &Sum[I]);
        int diff = Sum[I] - Sum[I - 1];
        Sequence[I] = diff;

        //validate
        for (int v = 1; v <= I; v++) {
            if (getMaxSumForRange(v) > Sum[v]) {
                printf("NIE\n");
                return 0;
            }
        }
    }
    printf("TAK\n");
    printf("%d\n", N);
    for (int i = 1; i <= N; i++) {
        printf("%d ", Sequence[i]);
    }
    return 0;
}