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

using namespace std;

long long calculateBoundary(vector<long long> fish){
    sort(fish.begin(), fish.end());
    long long boundary = 0;
    long long sum = 0;

    for(int i = 0; i < fish.size()-1; i++) {
        sum += fish[i];
        if(fish[i+1] >= sum)
            boundary = fish[i];
    }

    return boundary;
}

int main() {
    std::ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<long long> fish;
    for(int i = 0; i < n; i++) {
        long long nextFish;
        cin >> nextFish;
        fish.push_back(nextFish);
    }

    long long result = calculateBoundary(fish);

    for(int i = 0; i < n; i++) {
        if(fish[i] <= result)
            cout<<"N";
        else
            cout<<"T";
    }
    cout<<endl;
    return 0;
}