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
65
66
67
68
#include <bits/stdc++.h>

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define fi first
#define se second
#define ll long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define MAXN 100001

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    vector<ll> F(n);
    map<ll, int> C;

    ll w;
    for (int i = 0; i < n; i++) {
        cin >> w;
        F[i] = w;
        if (C.find(w) == C.end())
            C[w] = 0;
        C[w]++;
    }

    vector<ll> V(C.size());
    vector<ll> S(C.size());

	int j = 0;
    for (auto it = C.begin(); it != C.end(); ++it) {
        V[j] = (it->first);
        ll last = 0;
        if (j > 0) {
            last = S[j - 1];
        }
        S[j] = ((it->first) * ((ll) (it->second)) + last);
		j++;
    }

    int m = V.size();
	if(m > 1)
    	C[V[m - 1]] = -1;

    for (int i = m - 2; i > 0; i--) {
        if (V[i + 1] < S[i]) {
            C[V[i]] = -1;
        } else {
            break;
        }
    }

    for (int i = 0; i < n; i++) {
        char ans = C[F[i]] == -1 ? 'T' : 'N';
        cout << ans;
    }

    cout << endl;

    return 0;
}