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
#include<cstdio>
#include<algorithm>

int input[600*1000];
int cpy[600*1000];

int main() {
    int n;
    scanf("%i", &n);
    
    for (int i = 0; i < n; ++i) {
        int tmp;
        scanf("%i", &tmp);
        input[i] = -tmp;
        cpy[i] = tmp;
    }
    
    std::sort(input, input+n);
    
    for (int i = 0; i < n; ++i)
        input[i] *= -1;
    
    long long s = 0LL;
    for (int i = 0; i < n; ++i)
        s += input[i];
    
    int w = input[0];
    for (int i = 1; i < n; ++i) {
        s -= input[i-1];
        if (input[i-1] < s) {
            w = input[i];
        } else {
            break;
        }
    }
    
    if (w == input[n-1])
        w++;
    
    for (int i = 0; i < n; ++i) {
        //printf("%i", input[i]);
        if (cpy[i] >= w)
            printf("T");
        else
            printf("N");
    }
    printf("\n");

    return 0;
}