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
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

char czy(int n, int listy[500000], int num){
    int stara_suma = 0;
    int nowa_suma = 0;
    int niez = listy[num];
    stara_suma = listy[num];
    //int lista[n] = {}
    //lista = listy
    sort (listy - 1, listy + n - 1);
    for (int y = 0; y < n; y++){
    nowa_suma = 0;
    stara_suma = niez;
    for (int e = 0; e < n; e++){
        nowa_suma = listy[e];
        if ((stara_suma + nowa_suma) > listy[e] && e != num){
            stara_suma += listy[e];
        }
        else if ((stara_suma + nowa_suma) <= listy[e + 1]){
            //cout << "nie " << stara_suma + nowa_suma << endl;
            return 'N';
        }
    }
    }
    //cout << stara_suma + nowa_suma << endl;
    return 'T';
}

int main()
{
    int n;
    cin >> n;
    int lista[n] = {};
    char odp[n] = {};
    int akt;
    for (int i = 0; i < n; i++){
        cin >> akt;
        lista[i] = akt;
    }
    for (int f = 0; f < n; f++){
        cout << czy(n, lista, f);
    }
    
    return 0;
}