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
60
61
62
63
64
#include<cstdio>
#include<algorithm>
#include<vector>
#define S 500007
using namespace std;
typedef long long ll;

vector < int > V;

int n;

bool check(int x){
    ll tmp = V[x];
    for(int i = 0; i < n;i++){
        if(i != x){
            if(tmp > V[i]){
                tmp += V[i];
            }else{
                return false;
            }
        }
    }
    return true;
}

int T[S];

int bin(){
    int l = 0;
    int r = n-1;
    int sr;
    while(l < r){
        sr = (l+r)/2;
        if(check(sr)){
            r = sr;
        }else{
            l = sr+1;
        }
    }
    return l;
}

int main(void){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&T[i]);
        V.push_back(T[i]);
    }
    sort(V.begin(),V.end());
    int mini;
    if(V[0] == V.back()){
        mini = 1e9 + 7;
    }else{
        mini = V[bin()];
    }
    for(int i = 1; i <= n;i++){
        if(T[i] >= mini){
            printf("T");
        }else{
            printf("N");
        }
    }
    return 0;
}