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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;

        long long sum = 0;
        long long maxVal = 0;

        for (int i = 0; i < n; ++i) {
            long long x;
            cin >> x;
            sum += x;
            if (x > maxVal) maxVal = x;
        }

        // Warunki:
        // 1. Suma musi być nieparzysta.
        // 2. Żadna liczba a[i] nie może być większa niż sum/2 + 1
        if (sum % 2 == 1 && maxVal <= (sum + 1) / 2)
            cout << "TAK\n";
        else
            cout << "NIE\n";
    }

    return 0;
}