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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void C() {
    int n;
    cin >> n;
    vector<int> fish(n, 0);
    vector<int> data(n, 0);
    int a;
    for (int i = 0; i < n; i++){
        cin >> a;
        fish[i] = a;
        data[i] = a;
    }

    sort(data.begin(), data.end());
    int minMass = data[0] + 1;
    long long lowSum = data[0];

    for (int i = 1; i < n; i++){
        if (data[i - 1] != data[i]) {
            if (lowSum <= (long long)data[i])minMass = data[i];
        }
        lowSum += data[i];
    }
    if (n == 1)minMass = 0;

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

int main()
{
    C();
    return 0;
}